Trigger Not match

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi,

I'm not sure if I am doing right thing. I am still learning how to use
"DLookup".

I have two tables that are similar but Country might be different.
For example:

#1) If I enter record number and if Table A and Table B are the same then
no message box pop up. OR

#2) If I enter record number and if Table A and Table B have different
country then the message box pop up and advise me what country at Table B.

***********************
varRecordNumber = DLookup("[MyField_A]", ("MyTable_A"), "[MyField_A] = '" &
varNumber & "'")
varCountryNotMatch = DLookup("[MyField_B]", ("MyTable_B"), "[MyField_B] <>
'" & varCountry & "'")

If IsNull(varCountryNotMatch) Then
'MsgBox "............", vbOKOnly, "......"
************************

Your help would be much appreciated.
Thanks
 
Bill said:
I'm not sure if I am doing right thing. I am still learning how to use
"DLookup".

I have two tables that are similar but Country might be different.
For example:

#1) If I enter record number and if Table A and Table B are the same then
no message box pop up. OR

#2) If I enter record number and if Table A and Table B have different
country then the message box pop up and advise me what country at Table B.

***********************
varRecordNumber = DLookup("[MyField_A]", ("MyTable_A"), "[MyField_A] = '" &
varNumber & "'")
varCountryNotMatch = DLookup("[MyField_B]", ("MyTable_B"), "[MyField_B] <>
'" & varCountry & "'")

If IsNull(varCountryNotMatch) Then
'MsgBox "............", vbOKOnly, "......"
************************


Your DLookups are returning the record number not the
country and the second one is searching for the country that
was already entered. Also, if the record number really is a
number and not a text field, then you should not use a quote
around the number.

I think this is all you need:

***************************
varCountryNotMatch = DLookup("[countryfield]", _
("MyTable_B"), "[MyField_B] <> " varNumber)

If varCountry <> varCountryNotMatch Then
MsgBox . . .

If I've misunderstood your situation, then pleas post back
with more details about the fields in each table.
 
Hi Bill,

Thanks MVP's excellent answer. I wanted to post a quick note to see if you
would like additional assistance or information regarding this particular
issue. We appreciate your patience and look forward to hearing from you!

Thank you for your patience and cooperation.


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 
Back
Top