Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Current Record Problem 1

Status
Not open for further replies.

hende10

MIS
Aug 22, 2002
93
US
There is something odd (and probably simple) I can't figure out on my form. I originally designed it with a command button which would open a report showing only the current record. I started with the following code:

Dim strWhere As String
DoCmd.RunCommand acCmdSaveRecord
stDocName = "repRejNotice"
strWhere = "[RejPartQty]=" & Me!RejPartQty
DoCmd.OpenReport stDocName, acPreview, , strWhere

where RejPartQty is a number. This worked, but it reported all records that had the same qty that was active, i.e. if the current record had a qty of 5, the report listed all other records with a qty of 5, too.

To get around this, I'm trying to replace the qty field with my autonumber, RejAutoNum. My string statement is now:

strWhere = "[RejAutoNum]=" & Me!RejAutoNum

When I click the command button, this now prompts me to input a RejAutoNum value, then reports all records regardless of what value I put in.

Is this a formatting problem, or is there a problem with using an autonumber (and my primary key) for this function?

Thanks in advance!
 
My guess is that your autonumber field, "RejAutoNum" is not actually on your form, just in the table. If you put this field onto your form, but make it hidden (Visible = false), then it will be available for you when you do your strWhere = "[RejAutoNum]=" & Me!RejAutoNum

 
I expect the RejAutoNum is not in the Report's Record Source.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thank you both for answering. The [RejAutoNum] field was in the table, but I had forgotten to add it to the query that drives the report, thus the annoying prompt.

Thank you!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top