Printing only form in view

Keiath

Registered User.
Local time
Today, 21:15
Joined
Jan 6, 2012
Messages
104
Hi,

I have a Form 'Case'

and i set up a button so that it would only print the report for the form i am looking at.

DoCmd.OpenReport "Report1", , , "[Case]=" & Me.CaseNumberID

But its still printing all the forms, can anyone tell me what I am doing wrong?



Thanks
 
I suspect that CaseNumberID is actually defined, in the Table, as a Text Datatype and your syntax is only correct for a Number Datatype. Try

"[Case]='" & Me.CaseNumberID & "'"

Linq ;0)>
 
The CaseNumber is an autonumber and primary key
 
Case being a reserved word is probably a poor choice for a field name.
Whats the recordsource of the report? Are you sure it shouldnt be "[CaseNumberID]= " & Me.CaseNumberID ?
 
Are you, perhaps, entering a New Record, then immediately pressing the button to print your Report? If so, the problem may be that the Record hasn't been saved, yet. Try

Code:
If Me.Dirty Then Me.Dirty = False
 
DoCmd.OpenReport "Report1", , , "[Case]=" & Me.CaseNumberID

BTW, Case is not a Reserved Word, unless this has changed since Access 2007. One of the nicer new features, added in 2007, is that the Access Gnomes will warn you if you attempt to name a Field with a Reserved Word!

Linq ;0)>
 
Last edited:
Do you have a form object in your report?
 
BTW, Case is not a Reserved Word, unless this has changed since Access 2007. One of the nicer new features, added in 2007, is that the Access Gnomes will warn you if you attempt to name a Field with a Reserved Word!

case appears on several lists as a db engine reserved word including 2007. i always try to err on the side of caution to avoid those pesky gnomes.
I am a little perplexed however that the documentation does say that access will throw up a warning as you point out, but i just made a table with about 25 reserved words and symbols and no warning:confused:
 
I have a small v2003 db for checking Reserved Words (don't remember where I got it from) and didn't find it there, but knowing how often even info from the 'horse's mouth' is incorrect, when it comes to product out of Redmond, I double-checked the word with an actual MS site and it is not listed there either. Having said that, I'd probably not use the word, either, as it might confuse those pesty Gnomes!

Running v2007, with a file saved as an accdb file, I get a warning when trying to save a Field with a name that is also a Reserved Word...don't know why it's not working for you.

Linq ;0)>
 
It must be a reserved word as you use it in Select Case...
 

Users who are viewing this thread

Back
Top Bottom