dlookup with if

D

deb

Access 2003

On the form called fClosure ApprovalPopUp I have a combobox called
SignaturePM.
The default value for SignaturePM is currently
=DLookUp("[ContactPMID]","[t040Project]","[ProjectID] =" &
[Forms]![fClosure]![ProjectID])

How do I edit the above DLookUP to this...
=if LoginUser = PMUser then
DLookUp("[ContactPMID]","[t040Project]","[ProjectID] =" &
[Forms]![fClosure]![ProjectID])
if LoginUser = ManagerUser then
DLookUp("[ContactPMgrID]","[t040Project]","[ProjectID] =" &
[Forms]![fClosure]![ProjectID])
End if
End if

I get invalid syntax error if I use this in the Default Value area.
Thank you,
 
D

Daryl S

Deb -

Assuming you know if the LoginUser is PMUser or ManagerUser when the form is
first opened, then use the form's Load event to set the default value. This
example uses a simple if/then/else. If you have more than two LoginUsers,
then you can put this into a case statement.

If LoginUser = PMUser Then
Me.SignaturePM.DefaultValue =
DLookUp("[ContactPMID]","[t040Project]","[ProjectID] =" &
[Forms]![fClosure]![ProjectID])
Else
Me.SignaturePM.DefaultValue =
DLookUp("[ContactPMgrID]","[t040Project]","[ProjectID] =" &
[Forms]![fClosure]![ProjectID])
End If
 

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