dlookup with loop

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

In my fSplashForm I have a button called btnCloseApprove.
I only want it visible if ContactUserID =48 and ContactStatus =Active. How
do I add ContactStatus to the below code.

One more issue...
When the Dlookup finds the first ContactUserID it stops looking. There may
be more than one instance of the ContactUserID. How do I make it check the
whole table for
ContactUserID =48 even though it may find a ContactUserID =45 or 43
or??(other)

If DLookup("[ContactSubID]", "[t14Contacts]", "[ContactUserID] = '" &
Environ("username") & "'") = 48 Or _
DLookup("[User_Type]", "[tblVersion]", "[UserID] = '" & Environ("username")
& "'") = "Admin" Then
Me.btnCloseApprove.Visible = True
Else
Me.btnCloseApprove.Visible = False
End If
 
In my fSplashForm I have a button called btnCloseApprove.
I only want it visible if ContactUserID =48 and ContactStatus =Active. How
do I add ContactStatus to the below code.

One more issue...
When the Dlookup finds the first ContactUserID it stops looking. There may
be more than one instance of the ContactUserID. How do I make it check the
whole table for
ContactUserID =48 even though it may find a ContactUserID =45 or 43
or??(other)

If DLookup("[ContactSubID]", "[t14Contacts]", "[ContactUserID] = '" &
Environ("username") & "'") = 48 Or _
DLookup("[User_Type]", "[tblVersion]", "[UserID] = '" & Environ("username")
& "'") = "Admin" Then
Me.btnCloseApprove.Visible = True
Else
Me.btnCloseApprove.Visible = False
End If

DLookUp returns only one value. That's how it's designed!

If you want to return multiple values, DLookUp is not the appropriate tool;
you'll want to create a Recordset based on a query. It's not quite clear what
you're trying to accomplish though!
 
Back
Top