dlookup with loop

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
 
J

John W. Vinson

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top