jenny23 said:
Hello Mike,
I have done that.
What 's next?
Thanks.
Jenny,
Ok then!! I will assume you have not made a macro before......we are about to make a real simple one, but a couple of things first up.
In this exercise I will call your form that you wsant to print from MainForm and the copy you made PForm. You just insert the actual names.
Now for this to work you need to have an entry in each record that is unique to that record, such as an autonumber field or some other field that has unique information. For example, Surname would be no good because you might have (or will end up having) more than one person with the same surname.
Anyway, whatever the field is that has a unique value for each record I will call [NameNumber] and you just insert your actual field name.
So we have MainForm for the frm from which you want to print.
We have PForm for the copy you made.
We have NameNumber representing your unique field.
Making a macro looks a bit like making a table and you go to New macro and the macro design screen will open.
Note: Your version of Access might be a bit different to what I use. So if you have trouble then post this part up on the Macro forum and someone will quickly translate to your version but I think we will be Ok anyway for the type of simple macro we are about to make.
When the screen opens on new macro in design view you will see that it looks a bit like a table in design view.
There are two colums Conditions and Action. Conditions probably won't be displaying but if you clicked on View on the toolbar and then clicked Conditions it will appear. However, we won't need Conditions for this macro.
The first thing to do is click on the first line of the Action column and a drop down list arrow will appear. From this list find OpenForm and click on it.
When you do that OpenForm will appear on the action line and set of boxes will appear at the bottom of the screen and they should look something like this
Form Name
View
Filter Name
Where Condition
Data Mode
Window Mode
View will have defaulted to Form, Data Mode should have defauted to Edit and Window Mode should have defaulted to Normal.
Now for form name enter the name of the form which you made as a copy.
The only other one you need to worry about is Where condition and in that box enter.
[NameNumber]=[Forms]!MainForm]![NameNumber]
Remember you enter the name of the form you will launch Print from in place of where I have MainForm and enter the field name of your unique field where I have NameNumber.
Now you save this macro just as you would a form or table and it might default to a name like Macro1.
Now at this stage we have not included Print as we want to make sure your macro is opening the seconds form you made on a record that matches your main form.
Two things to do now to test.
Go to your MainForm in Design View and attach the Macro to an OnClick event. That might be a command button or you might make a label from the tool box.
Note: Label that appear on the form as a result of you dragging fields to the form from the field list do not have the facility for the various events. If you have any trouble in this area with making a label or command button then just attach (for now) the macro to OnClick event for one of the textboxes you have.
One you attached the macro I want you to go to the copy of the form you made and in Design View. In Design view change a few colours so that when the macro opens the form you will instantly see that it is a different form that has opened.
If we have success on this section then the rest is real easy.
When you run the macro the form should open with the matching record and say at the navigation buttons 1 of 1 filtered.
Then click the print icon.
If all is well, then we go back and add a couple of lines to the macro. One will be for the Printing and the other will close form.
It is nealry midnight here in Sydney Australia so if I miss you I will check in the morning as I will go to bed in an hour or so.
Good luck
Mike