PDA

View Full Version : [SOLVED:] Update to form not going to record source



InLaNoche
07-30-2014, 07:50 AM
I have some wierd thing going on with my Access 2013 database. I have a form base on a query. On that form I have a text box that is controled by one of the fields of the query. Simple stuff. When I make changes to the form (changes are shown in a list box) I run code to populate the text box :

[Private Sub Update_OfficeBox()
Dim listCount As Integer
Dim i As Integer
Dim strList As String

'default the strList to "" incase there are no items to add
strList = ""
Me.BoxNos = strList
'check how many BoxNos are in the listing
listCount = Me.TheseBoxNo.listCount

Debug.Print "listCount is " & listCount

For i = 0 To listCount - 1
'Debug.Print Me.TheseBoxNo.ItemData(i)
strList = strList + Me.TheseBoxNo.ItemData(i) + ", "
Debug.Print strList
Next

Me.BoxNos.Value = strList

End Sub

All seems to look right on the form. The text box shows the same value as the debug output. The problem is the actual query does not show the same value... It's almost as if it is delayed for some reason. As an example, I am adding 3 values to the list box in this order:
3A300D1
3A300D2
3A300D3

the first thing that is odd is that the last value goes to the top. There is really no reason for it to do this, the autonumber is the largest, and no matter what order I add them, D3 is aways at the top, then D1 then D2. That I can live with. But even though the text box on the form shows :

3A300D1, 3A300D2, 3A300D3,

when I open the query, 3A300D3 is missing. Here's the capper. If I remove it from the list (not showing in the listbox, and not showing in the field on the form) it then appears in the query. The above code is the only place I add the value. I have gone in and delete all values in the field on the query and tried again. Same thing...:banghead::banghead::banghead::banghead::banghead:

jonh
07-30-2014, 11:11 AM
Add me.requery before the end sub.

InLaNoche
07-30-2014, 11:43 AM
:doh:

Yes, this fixes the issue. The order thing I sorted out by forcing a sort in the definition for the listbox.

actually, instead I did a me.refresh, this way it does not reset my list boxes and the current record I am on.
Thanks.