Checking Two Conditions in a Macro

J

Jani

Is there a way to check two conditions in a macro at the same time? I want to
check to see if both a date and name are in a table before appending the
data. These need to be checked at the same time as in the dbo table there
could be the same date from another 'name' or the 'name' could be for a
different date. My current code is shown below and the error message states
that the tblDots can't be found but I know it is in the database. Any help
would be appreciated. Thanks! Jani

[tblDots]![Name]=[dbo_uDotsAll]![Name] &
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]
 
D

Douglas J. Steele

They're boolean expressions. Use the And operator:

[tblDots]![Name]=[dbo_uDotsAll]![Name] And
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]
 
J

Jani

Geez - you're quick! I changed to AND and am still getting a message that the
tblDots can't be found. The message is 'you may have specified a control that
wasn't on the current object without specifying the correct form or report
context. I tried entering
! and then table! preceding the code but
those didn't work. Any ideas on what I'm doing incorrectly?

Douglas J. Steele said:
They're boolean expressions. Use the And operator:

[tblDots]![Name]=[dbo_uDotsAll]![Name] And
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jani said:
Is there a way to check two conditions in a macro at the same time? I want
to
check to see if both a date and name are in a table before appending the
data. These need to be checked at the same time as in the dbo table there
could be the same date from another 'name' or the 'name' could be for a
different date. My current code is shown below and the error message
states
that the tblDots can't be found but I know it is in the database. Any help
would be appreciated. Thanks! Jani

[tblDots]![Name]=[dbo_uDotsAll]![Name] &
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]
 
D

Douglas J. Steele

Sorry, I didn't notice that you were referring to a table. You can't refer
to fields in tables like that. You need to use DLookup to get a specific
value.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jani said:
Geez - you're quick! I changed to AND and am still getting a message that
the
tblDots can't be found. The message is 'you may have specified a control
that
wasn't on the current object without specifying the correct form or report
context. I tried entering
! and then table! preceding the code but
those didn't work. Any ideas on what I'm doing incorrectly?

Douglas J. Steele said:
They're boolean expressions. Use the And operator:

[tblDots]![Name]=[dbo_uDotsAll]![Name] And
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jani said:
Is there a way to check two conditions in a macro at the same time? I
want
to
check to see if both a date and name are in a table before appending
the
data. These need to be checked at the same time as in the dbo table
there
could be the same date from another 'name' or the 'name' could be for a
different date. My current code is shown below and the error message
states
that the tblDots can't be found but I know it is in the database. Any
help
would be appreciated. Thanks! Jani

[tblDots]![Name]=[dbo_uDotsAll]![Name] &
[tblDots]![DistDate]=[dbo_uDotsAll]![DistDate]
 

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