If statement with select query

S

Stephen Lynch

Cab I use a select statement as part of an if, then statement?

For example

If

SELECT Count(tblRetireHQImportTEMP.ErrorMsg) AS CountOfErrorMsg FROM
tblRetireHQImportTEMP HAVING (((Count(tblRetireHQImportTEMP.ErrorMsg)) Like
'Error*'))>0'"

Then

DoCmd.OpenForm

Else

Whatever!


I want to count the number of records with an error message and if greater
than zero open form1 otherwise form2..

Thanks

Steve
 
M

Marshall Barton

Stephen said:
Cab I use a select statement as part of an if, then statement?

For example

If

SELECT Count(tblRetireHQImportTEMP.ErrorMsg) AS CountOfErrorMsg FROM
tblRetireHQImportTEMP HAVING (((Count(tblRetireHQImportTEMP.ErrorMsg)) Like
'Error*'))>0'"

Then

DoCmd.OpenForm

Else

Whatever!


I want to count the number of records with an error message and if greater
than zero open form1 otherwise form2..


No, but you can use an equivalent Domain Aggregate function:

If DCount("*", "tblRetireHQImportTEMP", "ErrorMsg Like
'Error*') > 0 Then
 

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