I'm doing something wrong.
1. Note command name changed to Command12711 (I deleted the other)
The name of the command is COMPLETELY IRRELEVANT.
2. Report is based on query named envelope1
3. Query contain unique field that is auto number
What's the name of that unique field? CaseID? Tables can have
autonumbers, and queries can include an autonumber field from the
table - but a query cannot have an autonumber in its own right.
4. I put a text box field on my Cases form
5. Text box Control Source: CaseID
6. Text box named: Text12712
In event I did as follows, but received error message:
DoCmd.OpenReport strDocument,WhereCondition :="[CaseID]="_& Me!Text12712
It is obvious I do not understand the theory behind what I am trying to do.
Should the textbox on the Cases form have the same name in the event
property of the Command button?????
No. It should not. A command button is one type of control; a textbox
is a completely different type of control.
Are you putting this line *directly in the Click event property*? If
so, that's the problem! Delete the command button from your form, and
use the toolbox Wizard to create a new Button, using the option "use
this button to open a report". This will give you
[Event Procedure]
on the Property line and about a 15-line VBA function - *including* a
line with DoCmd.OpenReport on it. You can edit that function as above.
The theory is that you're using the button to run some VBA code to
open a Report. The DoCmd.OpenReport method is the line which opens a
report; its first argument is the name of the Report (the name of that
report's query is not needed here), which the button wizard puts into
the string variable strDocument. An optional argument to the
OpenReport method is its WhereCondition argument. If what you have is
literally what you posted above, get rid of the underscore - I was
putting it in because my newsreader wraps text lines and I was using
the underscore as a line-continuation character.
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps