Error trapping a combobox?

NewShoes

Registered User.
Local time
Today, 15:15
Joined
Aug 1, 2009
Messages
223
Hey all,

I have a simple form with a combo box that filters a subform. However, there is a little issue when the user clears the combobox by clicking in and deleting the text then hitting enter or clicking out of the combox box, it produces an error (and if in runtime mode, it will close the whole thing down).

Please can anyone let me know how to error trap this? I tried using Access's macro builder and the OnError option but this didn't seem to help.

Many thanks,
-NS
 
Can you show us the code that filters the sub form? I would expect to find this in the After Update event of the combo box.
 
You can try this.

Code:
Option Compare Database

Private Sub Combo0_AfterUpdate()
If IsNull(Me.Combo0) Then
Me.Combo0 = Nz(Me.Combo0.Tag, Me.Combo0.DefaultValue)
MsgBox "Error", , "Title"
Else
Me.Combo0.Tag = Me.Combo0
End If
End Sub



Private Sub Form_Open(Cancel As Integer)
Me.Combo0.DefaultValue = Me.Combo0.ItemData(0)
End Sub
 
Thanks for the replies. It tunrs out that I just needed to save the current record before requerying!

-NS
 

Users who are viewing this thread

Back
Top Bottom