Print specific records...

G

Guest

Hey all:

Besides the code, is there any thing else I must do to print secific records.
This is the code I got from this NG.

DoCmd.OpenReport "Sales", acPreview
Reports![YourReport].Filter = "Customer = " & Me![Customer]
Reports![YourReport].FilterOn = True

Customer is my primary key.

When I click my Print button I get this error message:

Syntax error (missing operator) in query expression '(Customer = blah blah)'.

I'm supposed to use a filter (I think) as well but I'm not sure how it
works(or how to implement).

Would like to just be able to ONLY print the current record.

Please help.
 
A

Albert D.Kallal

jsc3489 said:
Hey all:

Besides the code, is there any thing else I must do to print secific
records.
This is the code I got from this NG.

DoCmd.OpenReport "Sales", acPreview
Reports![YourReport].Filter = "Customer = " & Me![Customer]
Reports![YourReport].FilterOn = True

Customer is my primary key.

You code is correct if customer is a autonumber, or simply a "number" type
field (usually a long type field).

I have to assume the in your case, customer is a "text" type field...so you
have to "quotes" for text type fields.

And, better to use the following code:

if me.dirty = true then
me.dirty = false
end if
DoCmd.OpenReport "Sales", acViewPreview,,"Customer = '" & me!Customer & "'"

In your example, you open report , and ALL records get loaded. You then put
a filter on "after".
So, while you example might work if you fixed the "quotes" as I have...using
the "where" clause is preferred.

In the above example, note the "test" to see if the current records needs to
be written to disk. The me.dirty = false forces a disk write (you need to
write to disk..as the report will read from the table..but your current
changes in the form will now show unless you forced the disk write..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top