Hello programmers,
I entered this code below in the after update of a drop down box in a form. The string strFilter works well after the selection is made but the strFilterTwo doesn't unless you select it again from the drop down box and then it does the update. Any insights?
Private Sub UserID_AfterUpdate()
On Error GoTo Err_UserID_AfterUpdate
Dim strFilter As String
Dim strFilterTwo As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "UserID = " & Me!UserID
strFilterTwo = "PropertyID = " & Me!PropertyID
' Look up user' ID and assign it to PropertyID control.
Me!PropertyID = DLookup("PropertyID", "tblUser", strFilter)
' Look up property ID and assign it to PropertyName control.
Me!PropName = DLookup("PropertyName", "tblProperty", strFilterTwo)
Exit_UserID_AfterUpdate:
Exit Sub
Err_UserID_AfterUpdate:
MsgBox Err.Description
Resume Exit_UserID_AfterUpdate
End Sub
I entered this code below in the after update of a drop down box in a form. The string strFilter works well after the selection is made but the strFilterTwo doesn't unless you select it again from the drop down box and then it does the update. Any insights?
Private Sub UserID_AfterUpdate()
On Error GoTo Err_UserID_AfterUpdate
Dim strFilter As String
Dim strFilterTwo As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "UserID = " & Me!UserID
strFilterTwo = "PropertyID = " & Me!PropertyID
' Look up user' ID and assign it to PropertyID control.
Me!PropertyID = DLookup("PropertyID", "tblUser", strFilter)
' Look up property ID and assign it to PropertyName control.
Me!PropName = DLookup("PropertyName", "tblProperty", strFilterTwo)
Exit_UserID_AfterUpdate:
Exit Sub
Err_UserID_AfterUpdate:
MsgBox Err.Description
Resume Exit_UserID_AfterUpdate
End Sub