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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After update in VB for a form assistance 1

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
0
0
US
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
 
How about;

Code:
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

' Look up user' ID and assign it to PropertyID control.
Me!PropertyID = DLookup("PropertyID", "tblUser", strFilter)

strFilterTwo = "PropertyID = " & Me!PropertyID

' 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
 
It worked! Thank you very much. Good Eye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top