Problem with IF statement.

  • Thread starter Thread starter Paul3rd
  • Start date Start date
P

Paul3rd

Hello,
Does a rule exist forbidding an operator used in an IF statement?
If not, why won't the following statement work?
If Me![Check154].Value = True And Me![txtSpkExch] = 4 Then
DoCmd.OpenReport stDoc3WO, acViewNormal
Is it because of my syntax?
Thanks in advance for any help,
Paul
 
Is that all one line, or two lines? If it's two lines, do you have an End If
afterwards?

What error are you getting?
 
Hello,
That is two lines, and there is an End If afterwards.
I'm not getting an error but the report won't open.
It's as if there is an Exit Sub command.

Douglas J. Steele said:
Is that all one line, or two lines? If it's two lines, do you have an End If
afterwards?

What error are you getting?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Paul3rd said:
Hello,
Does a rule exist forbidding an operator used in an IF statement?
If not, why won't the following statement work?
If Me![Check154].Value = True And Me![txtSpkExch] = 4 Then
DoCmd.OpenReport stDoc3WO, acViewNormal
Is it because of my syntax?
Thanks in advance for any help,
Paul
 
Paul3rd,
No, an IIF statement can use any legitimate operator/s.
Try...

If Me.[Check154] = True And Me.[txtSpkExch] = 4 Then
DoCmd.OpenReport "stDoc3WO"
End If

acViewNormal is the default for the OpenReport Method (if no View
argument is indicated), so... no need to include it.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Hi Al,
That didn't work either, and interestingly:
If Me.[Check154] = True And Me.[txtSpkExch] = 4 Then
MsgBox ("It's 4")
did not cause a Message Box to appear, although I know both statements
to be true.
Paul
Al Campagna said:
Paul3rd,
No, an IIF statement can use any legitimate operator/s.
Try...

If Me.[Check154] = True And Me.[txtSpkExch] = 4 Then
DoCmd.OpenReport "stDoc3WO"
End If

acViewNormal is the default for the OpenReport Method (if no View
argument is indicated), so... no need to include it.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Paul3rd said:
Hello,
Does a rule exist forbidding an operator used in an IF statement?
If not, why won't the following statement work?
If Me![Check154].Value = True And Me![txtSpkExch] = 4 Then
DoCmd.OpenReport stDoc3WO, acViewNormal
Is it because of my syntax?
Thanks in advance for any help,
Paul
 
OK,
So I erased all the code in that block and retyped it....
now everything works fine.
Some days are like that.
Thanks,
Paul

Al Campagna said:
Paul3rd,
No, an IIF statement can use any legitimate operator/s.
Try...

If Me.[Check154] = True And Me.[txtSpkExch] = 4 Then
DoCmd.OpenReport "stDoc3WO"
End If

acViewNormal is the default for the OpenReport Method (if no View
argument is indicated), so... no need to include it.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Paul3rd said:
Hello,
Does a rule exist forbidding an operator used in an IF statement?
If not, why won't the following statement work?
If Me![Check154].Value = True And Me![txtSpkExch] = 4 Then
DoCmd.OpenReport stDoc3WO, acViewNormal
Is it because of my syntax?
Thanks in advance for any help,
Paul
 
Back
Top