combo box validation and opening a form

tubar

Registered User.
Local time
Yesterday, 20:25
Joined
Jul 13, 2006
Messages
190
i apologize in advance...i am very new and have much to learn. i have a combo box with the following code in the after update...i get the error "object required" can someone please guide me to a fix


Private Sub Combo0_AfterUpdate()
On Error GoTo Err_Combo0_AfterUpdate

Dim stDocName As String
Dim stLinkCriteria As String


If Combo0 Is between = "100210071001" And "100210079999" Then
DoCmd.OpenForm "PURCHASE 2", , , ""
Forms("PURCHASE 2").Controls("CUSTOMERS").Value = Me.[Combo0]
Me.Form.SetFocus
DoCmd.Close acForm, Me.Name
Else
MsgBox "THIS IS NOT A VALID CUSTOMER"
Cancel = True
End If
Exit_Combo0_AfterUpdate:
Exit Sub

Err_Combo0_AfterUpdate:
MsgBox Err.Description
Resume Exit_Combo0_AfterUpdate



End Sub
 
Your IF statement is causing your object required error. It's looking for the variable named "between" and can't find it. Try this:

Code:
If Me.Combo0 >= "100210071001" And Me.Combo0 <= "100210079999" Then
 
that worked BEAUTIFULLY!!!! however the combo0 is a look up field so the number 100210071001 is actually id 7 in the upc table. STUPID LOOK UP FeILDS!!!...is there a way to fix my code to focus on the 100210071001 number and not the id? i m so sorry for lack of terms...i am a newbie!
 
Try changing it to Me.Combo0.Text. That will give you the number that actually appears in the box instead of the data behind it.
 
Still didnt work:( current code is

Private Sub Combo0_AfterUpdate()
On Error GoTo Err_Combo0_AfterUpdate

Dim stDocName As String
Dim stLinkCriteria As String


If Me.Combo0.Text >= "100210071001" And Me.Combo0 <= "100210079999" Then
DoCmd.OpenForm "PURCHASE 2", , , ""
Forms("PURCHASE 2").Controls("CUSTOMERS").Value = Me.[Combo0]
Me.Form.SetFocus
DoCmd.Close acForm, Me.Name

Else
MsgBox "THIS IS NOT A VALID CUSTOMER"

End If
Exit_Combo0_AfterUpdate:
Exit Sub


Err_Combo0_AfterUpdate:
MsgBox Err.DESCRIPTION
Resume Exit_Combo0_AfterUpdate



End Sub
 
Your second Me.Combo0 doesn't have the .text on it.
 

Users who are viewing this thread

Back
Top Bottom