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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter records to be printed 1

Status
Not open for further replies.

DavidDF

MIS
Jan 19, 2003
8
US
I wish to print part of the current record (not a print screen format) from an Access 2000 form. Here is part of the code:

1 Dim StrDocName As String
2 Dim StrWhere As String

3 StrDocName = "CurrentRecReport"

** the field CustomerNum is a numeric,AutoNumber field
4 StrWhere = Str("CustomerNum]=") & me!CustomerNum
5 DoCmd.OpenReport StrDocName,acPreview, StrWhere

I know there is an error in line 4. What should the correct code be? Any help would be appreciated.

David
 
David,

In order to tell the compiler that you are choosing a field you should use [..]'s.

StrWhere = "[CustomerNum] = " & me![txtCustomerNum]

The brackets tell the compiler to look for a field. Note the left hand entity and the right hand entity must be different or you are saying: "When I am I or when 2 = 2"

I supposed that you had a textbox associated with the form which is aliased by 'me.'

rollie@bwsys.net
 
Thank you so much! I changed your suggestion a little and it worked within a couple of minutes. Here is what I did:

StrWhere = "[CustomerNum] = " & Me![CustomerNum]
DoCmd.OpenReport StrDocName,,, StrWhere

Extra commas in DoCmd line are placeholds so StrWhere is
recognized. It printed current record in the label report format I had already set up.

Since I want this to print as an envelope I want to add landscape code prior to printing then portrait after printing to set printer back to normal (I am using an HP PhotoSmart printer and operating system is Win XP Prof).
Thanks again!

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top