An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source.
In case that table is already created, and the combo box value is to be changed again, the temp. table needs to be deleted and the form needs to be requeried. I use on before update event of the combo box:
Expand|Select|Wrap|Line Numbers
- Private Sub citylist_BeforeUpdate(Cancel As Integer)
- If DCount("CusId", "tblTempDist") > 0 Then
- If MsgBox("This will reset the temprorary list, continue?", vbExclamation + vbOKCancel _
- , strProjectTitle) = vbCancel Then
- Cancel = True
- DoCmd.CancelEvent
- SendKeys "{ESC}", False
- Exit Sub
- Else
- 'user agrees to reset
- Cancel = False
- DoCmd.RunSQL " delete * from tblTempDist; "
- Me.Requery ' here the error appears
- Exit Sub
- End If
- Else
- Cancel = False
- End If
- End Sub
Replacing Me.Requery with Me.cusId.SetFocus returns the following error: Run-time error '2108': You must save the field before you execute the GoToControl action, the GoToControl method, or the SetFocus method
I don't understand the underling problem of this error, what am I doing wrong and how to solve this.
Need your help.
Thanks,
Michael.