Printing a record via a form? (1 Viewer)

donkey89

Registered User.
Local time
Today, 03:47
Joined
May 14, 2011
Messages
17
Hello there,

I'd like to start by saying I'm very new at this, Its a self project (sort of) and I aim to start small and develop it as I learn.

In a nutshell I'm creating a basic database that consists of a Main Menu linked to two forms (Customers and Orders) these are linked by a unique Customer ID. All has gone well so far with much help from viewing threads on these forums, so thankyou for that.

So to get to my problem:

I have created a report and organised it in a way I would like it be printed, however when I am on the Orders form, and click the button which I have linked to the report, It seems to go to one record every time regardless of which order I am currently viewing. So I'm looking for a solution to "bind" my report to the current record, which could be done by another unique field which is my "Order Number" however.. I'm not sure how to do this so any help would be greatly Appreciated!

~Markus.
 

donkey89

Registered User.
Local time
Today, 03:47
Joined
May 14, 2011
Messages
17
Thankyou for the link pbaldy,

I have tried to put this to use by doing the following:

I have created a new "blank" button so to speak, on the event 'On Click' I have added a event procedure with the following code;

------
Private Sub Command122_Click()

DoCmd.OpenReport "[Order Print Off]", , , "[Order Number] = " & Me.[Order Number]

End Sub
------

Unfortunately I did put spaces in all of my Fields/Tables/Forms etc so I believe I am correct to add the symbols '[]' however the button doesnt appear to do anything and I can't see where I have gone wrong.

The report name is 'Order Print Off', and the unique field on the initial order form is Order Number, I could also use Order ID as both appear on the Order Form and the Report which is literally just a more glamourous version of the Order form for printing purposes.

Any help would be great, Thankyou in advance

~Markus
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:47
Joined
Aug 30, 2003
Messages
36,124
As you have it, that would print to the default printer. You might try

DoCmd.OpenReport "[Order Print Off]", acViewPreview, , "[Order Number] = " & Me.[Order Number]

I assume Order Number is a numeric field?
 

donkey89

Registered User.
Local time
Today, 03:47
Joined
May 14, 2011
Messages
17
Thankyou pbaldy,

Unfortunately I have not had chance to check back here until now, I havn't tried your approach to my problem as I managed to solve it by using the Macro builder I believe, to your question though Order Number is a numeric field yes.

For anybody interested what I did was the following, created a button with a embedded macro "on click" with the following information.

For this I used the information you kindly supplied regarding the "Where condition".

Action: OpenReport
Arguments: rptPrintOrder, Report, , [OrderID]=Forms![fmOrders]!OrderID, Normal

Is there any downsides to using the above method opposed to using the code builder method?

Thankyou once more for your help!

~Markus
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:47
Joined
Aug 30, 2003
Messages
36,124
Happy to help! Code is more flexible, more powerful, supports error trapping, etc. That said, macros are a valid way to accomplish things, and if that macro does the job for you then stick with it.
 

Dick7Access

Dick S
Local time
Yesterday, 22:47
Joined
Jun 9, 2009
Messages
4,201
Hi donkey89 ,
I don’t usually try to help people here as there are so many people that know access way better than I do. I come to the forum often reading everything I can trying to learn by doing as you mention in your original post. That is a good way to learn to a certain extent. However, many years ago I started like the preverbal “Bull in a China Shop”. The mistake I made is not learning the little basics. For example I would name a field whatever pleased me at the time. Years later I can’t remember what one field called snowball does and snowfall does, because I did not put a description in the description Colum of the table design view.
I would take the default name for buttons that came up which is commandxxx. Now years later than I am trying to normalized my db (13,000+ record) and make it more user friendly I am having a difficult time because when I go into VBA I can’t tell one Commandxx from the next Commandxxx. Just a suggestion.
If you can tolerate one more suggestion you might want to consider filling out your profile.
 

Users who are viewing this thread

Top Bottom