Noob needs help with DLookup function in form

Try

If Account2 <> Account1 Then
...
End If
 
Okay, so I messed around with your suggestion, and came up with this:

If acct_num <> Account1 Then
Account2.Value = DLookup("acct_num", "[AMS_Accounts]", "acc_lnk_id=" & Link_ID)
End If


If acct_num <> Account2 Or Account1 Then
Account3.Value = DLookup("acct_num", "[AMS_Accounts]", "acc_lnk_id=" & Link_ID)
End If


However, I end up getting duplicates through it:

Account1: 12345678
Account2: 98765432
Account3: 98765432

And sometimes, depending on what account number is entered first, all three accounts could be the same.
 
This test is not valid:

If acct_num <> Account2 Or Account1 Then

You have to fully test each value, like:

If acct_num <> Account2 And acct_num <> Account1 Then
 
This test is not valid:

If acct_num <> Account2 Or Account1 Then

You have to fully test each value, like:

If acct_num <> Account2 And acct_num <> Account1 Then

Yeah, its still isn't working. Its as if I need to do the dlookup first, then set the value to the product of the dlookup. It seems like it compares acct_num to Account1, then just runs a dlookup that can produce anything - which can result in a duplicate.

Does that seem to make any sense?
 

Users who are viewing this thread

Back
Top Bottom