Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do do a lookup BeforeUpdate Event 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I have a form that allows a person to click a dropdown
ComboBox and select a training class they would like to
attend. I would like to do a BeforeEvent lookup to see
if they have already selected this class. If they have
I would like a pop-up to appear saying you have already
selected this class. Can anyone give me an example of how
this could be done with a look-up?
Fields involved are:
ClockNbr
FirstName
LastName
ClassSubject

Table involved is MasterInputTbl
 
Would this do the trick?
Code:
Private Sub MyCombo_BeforeUpdate(Cancel As Integer)
    If Not IsNull(DFirst("ClockNbr", "MasterInputTbl", _
        "[FirstName]='" & Me![FirstName] & _
        "' And [LastName]='" & Me![LastName] & _
        "' And [ClassSubject]='" & Me![MyCombo] & "'")) Then
        Cancel = True
        MsgBox "You have already selected this class."
    End If
End Sub
 
LisaWay,

Blessings to you!

That works great. Many Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top