A family of Microsoft relational database management systems designed for ease of use.
It sounds like you have quotes in the wrong places. Post a Copy/Paste of the code as you tried it.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to put a button on a form that will print a copy of a report (named: price tags) for the current record only
Any Ideas
Thanks
Jeff
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
It sounds like you have quotes in the wrong places. Post a Copy/Paste of the code as you tried it.
It asks me to:
"Enter Parameter Valve"
for
Me.number
("number" being my primary key field name)
If I enter a value, it still prints all the records
I can not get this to work. Not sure what I'm doing wrong
One thing I'd add is that you should ensure the form's current record is saved before opening the report. Otherwise any unsaved changes which might have been made to the record won't be reflected in the report, and if it's a new record nothing will be reported. Doing it in the button's Click event procedure rather than via a macro the code would be like this:
Dim strCriteria As String
strCriteria = "[primary key field name] = " & Me.[primary key field name]
' ensure current record is saved
Me.Dirty = False
' print report filtered to current record
DoCmd.OpenReport "Price Tags", WhereCondition:=strCriteria
If the key is a column of text data type amend the expression as described by Marshall.
Use the button wizard to create a macro to open the report. Then fiill in the WhereCondition parameter to match the record's primary key field to the form text box to the same field in the table. It may look vaguely like:
If the primary key field is a number data type:
"[primary key field name] = " & Me.[primary key field name]
if it's a Text field:
"[primary key field name] = """ & Me.[primary key field name] & """ "