C
Chuck216
Hi
I have the following code behind one of my forms to automatically fill in
the LastName, FirstName & Division when a hang tag number is typed into the
form. The data is retrieved from tblName which also has a “year†field in it.
Since tblName can contain many years worth of data I would like to only fill
the form with the current years data. I don’t know how to add the code to
only retrieve the data if the year field is equal to the current year .I hope
I’m making my question understandable ( sometimes I confuse myself ) any
help with this will be greatly appreciated .
Private Sub HangTag_AfterUpdate()
On Error GoTo Err_HangTag_AfterUpdate
Dim varX As Variant
Dim varY As Variant
Dim varZ As Variant
varX = DLookup("LastName", "tblName", "HangTag ='" & Me.HangTag & "'")
varY = DLookup("FirstName", "tblName", "HangTag ='" & Me.HangTag & "'")
varZ = DLookup("Division", "tblName", "HangTag ='" & Me.HangTag & "'")
Me.LastName = varX
Me.FirstName = varY
Me.Division = varZ
Exit_HangTag_AfterUpdate:
Exit Sub
Err_HangTag_AfterUpdate:
MsgBox Err.Description
Resume Exit_HangTag_AfterUpdate
End Sub
I have the following code behind one of my forms to automatically fill in
the LastName, FirstName & Division when a hang tag number is typed into the
form. The data is retrieved from tblName which also has a “year†field in it.
Since tblName can contain many years worth of data I would like to only fill
the form with the current years data. I don’t know how to add the code to
only retrieve the data if the year field is equal to the current year .I hope
I’m making my question understandable ( sometimes I confuse myself ) any
help with this will be greatly appreciated .
Private Sub HangTag_AfterUpdate()
On Error GoTo Err_HangTag_AfterUpdate
Dim varX As Variant
Dim varY As Variant
Dim varZ As Variant
varX = DLookup("LastName", "tblName", "HangTag ='" & Me.HangTag & "'")
varY = DLookup("FirstName", "tblName", "HangTag ='" & Me.HangTag & "'")
varZ = DLookup("Division", "tblName", "HangTag ='" & Me.HangTag & "'")
Me.LastName = varX
Me.FirstName = varY
Me.Division = varZ
Exit_HangTag_AfterUpdate:
Exit Sub
Err_HangTag_AfterUpdate:
MsgBox Err.Description
Resume Exit_HangTag_AfterUpdate
End Sub