Looking for specific value in Field - DCount??

Franky G

Registered User.
Local time
Today, 17:44
Joined
Feb 6, 2001
Messages
62
Hi,

I'm trying to check whether a field [Letter] in a table "Not Started List" has a specific value, 6M or 30M, if either of these values are present then I want to continue running a macro, otherwise msgbox 'No data, quitting'. Can I use DCount for this, or do I need something else? At the moment, my macro always runs as there are always other values in the Letter field.

If DCount("[Letter]", "Not Started List") > 0 Then
DoCmd.RunMacro ("Run 6 Month Not started Query")
else.....

Thanks for any pointers,

FrankyG
 
If DCount("[Letter]", "Not Started List", ((([Letter]) = '6M') OR (([Letter]) = '30M'))) > 0 Then
DoCmd.RunMacro ("Run 6 Month Not started Query")
else.....
 
Getting a compile error, Expected: expression

If DCount("[Letter]", "Not Started List", ((([Letter]) = '6M') OR (([Letter]) = '30M'))) > 0 Then
The red quote mark (above) is highlighted in the debugger, I'm trying to sort this now, but was wondering if it might be necesary to repeat the DCount statement for each value, like

If DCount("[Letter]", "Not Started List", ((([Letter]) = '6M') OR If DCount("[Letter]", "Not Started List", (([Letter]) = '30M'))) > 0 Then

bracketing is all wrong, but you know what I mean?

Thanks for your help,

FrankyG
 
If DCount("*", "Not Started List", "Letter='6M' or Letter='30M'") > 0 Then
 
Sorry missed out two quotation marks.

If DCount("[Letter]", "Not Started List", "((([Letter]) = '6M') OR (([Letter]) = '30M'))") > 0 Then
DoCmd.RunMacro ("Run 6 Month Not started Query")
else
 
Ok Jon, this worked;
If DCount("*", "Not Started List", "Letter='6M' or Letter='30M'") > 0 Then
I got my clumsy version working also,
If DCount("[Letter]", "Not Started List", "[Letter]= '6M'") Or DCount("[Letter]", "Not Started List", "[Letter]= '30M'") > 0 Then
and Mile-O, haven't tried your revised statement yet :)

Thank you, another project concluded with your help :D

Regards

FrankyG
 
Although the FindFirst method requires more coding, it is infinatley more quicker than DCount, DLooUp etc.
 

Users who are viewing this thread

Back
Top Bottom