Passing over Requery

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have a form, with a list box that has a query for the rowsource. The User
selects a command button that is supposed to take the selected value away
from the list box by updating a table then requerying the listbox.. I have
this working on a different form so I cannot understand what I did so
differently. The commented out code is the code that works. Why would
something not requery?

Private Sub CloseaCarton_Click()
Dim stFCarton As String
On Error GoTo Err_CloseaFCarton_Click

'capture the carton number from the list
stFCarton = AvailableFCartonList.Value

'Now construct insert statment
SQLStmt = "UPDATE FileCartonTable SET Carton Status = FASLE " & _
"WHERE (FileCartonNbr = " + CStr(stFCarton) + ")"

'Now execute SQL and insert
DoCmd.RunSQL (SQLStmt)

'Now refresh list box
Me.AvailableFCartonList.Requery

Err_CloseaFCarton_Click:
If IsNull(AvailableFCartonList.Value) Then
MsgBox "You must select an FC to Close", vbOKOnly, "Closing FCs"
End If
'
' 'capture the box number from the list
' stBoxNbr = AvailableBoxList.Value
'
''Now construct insert statment
' SQLStmt = "UPDATE BoxTable SET BoxStatus = FALSE"
' SQLStmt = SQLStmt + " WHERE (BoxNbr = " + CStr(stBoxNbr) + ")"
'
'
' 'Now Execute SQL and insert
' DoCmd.RunSQL (SQLStmt)
'
' 'Now refresh list box
' AvailableBoxList.Requery
'
' 'If available box list is null
'Err_Closeabox_Click:
'If IsNull(AvailableBoxList.Value) Then
' MsgBox "You must select a box to close", vbOKOnly, "Closing Boxes"
' End If
'

End Sub
.


Quantcast