Paul,
What are you expecting to happen with the stOption bit?
Firstly, what is chk_a? I assume it is a check box. If it is, then it can
have the values True or False and these are stored as -1 or 0. Therefore it
will never have a value of 1, so the expression "Me.chk_a = 1" will always
return "False", and the bit of code that sets the value of stOption will
never run.
(Try typing the following into the intermediate window, and see what gets
returned:
?True = True
?True = -1
?True = 1)
In fact you only need to put:
If Me.chk_a Then ...
as the value of chk_a will be True or false, and the expression that comes
after "If" just has to be something that returns a value of True or False.
Now, if you get the code to run and set the value of stOption, what is going
to happen? I assume you want to concatenate some strings to get a suitable
Where clause for opening your report. What you've actually put is:
stOption = "A*" + stOption = "B*" + stOption
I think this will be interpreted as:
stOption = "A*" + (stOption = "B*") + stOption
The middle term will be treated as a logical expression and will return a
value of "False", and I would expect this to give Run Time error 13 (type
mismatch) as you are trying to add two strings and the value False. If you
want to concatenate strings and numbers or values then the & operator will
do it, but if you just rewrite it as:
stOption = "A*" & (stOption = "B*") & stOption
Then this will just return "False" - I'm not quite sure that I can explain
why, but really it's not important as I doubt this is what you want to do.
Can you post back with what you think the value of stOption should be, and
what you want it to do? Then, I'm sure someone will be able to help you
further. If you type the following into the intermediate window:
DoCmd.OpenReport stDocName, acPreview, , "Some text here"
(replacing "Some text here" with what you want stOption to be), then you can
test that it does what you want without needing the whole procedure to work.
Also, what is the purpose of these variables in your procedure?
stDocName As String
db As Database
chkOption As Boolean