By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

Form Print with changed copies

P: n/a
I have an access project with a Form that has a Command button to
print the current record. I would like to Print the record 3 times,
changing a text field on each print.

The standard code of
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End sub
Works good for one copy.

I would like to do something like this:
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text1"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text2"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
end sub

I do keep getting error "SelectRecord" command isn't available.

Do I have to set focus back to the form??

Any ideas on how this can be done. Thank you for all your help.

Darren
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Darren DeCoste wrote:
I have an access project with a Form that has a Command button to
print the current record. I would like to Print the record 3 times,
changing a text field on each print.

The standard code of
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End sub
Works good for one copy.

I would like to do something like this:
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text1"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text2"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
end sub

I do keep getting error "SelectRecord" command isn't available.

Do I have to set focus back to the form??

Any ideas on how this can be done. Thank you for all your help.

Darren


I'm not sure that you have to set focus back to the form. I haven't tried
anything like this but as long as you can refer to the textbox you can
change it's value. Take out the setfocus lines and see what happens.

Nov 13 '05 #2

P: n/a
"Deano" <de*********@hotmail.com> wrote in message news:<41***********************@ptn-nntp-reader03.plus.net>...
Darren DeCoste wrote:
I have an access project with a Form that has a Command button to
print the current record. I would like to Print the record 3 times,
changing a text field on each print.

The standard code of
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End sub
Works good for one copy.

I would like to do something like this:
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text1"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text2"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
end sub

I do keep getting error "SelectRecord" command isn't available.

Do I have to set focus back to the form??

Any ideas on how this can be done. Thank you for all your help.

Darren


I'm not sure that you have to set focus back to the form. I haven't tried
anything like this but as long as you can refer to the textbox you can
change it's value. Take out the setfocus lines and see what happens.

I originally did not have the setfocus and I would get an error
telling me that I could not change the textbox properties since it did
not have the focus. That is the main reason I used the setfocus
command. I would prefer not having to set the focus but I thought
that it was neccessary.

Thank you
Darren
Nov 13 '05 #3

P: n/a
Darren DeCoste wrote:
"Deano" <de*********@hotmail.com> wrote in message
news:<41***********************@ptn-nntp-reader03.plus.net>...
Darren DeCoste wrote:
I have an access project with a Form that has a Command button to
print the current record. I would like to Print the record 3 times,
changing a text field on each print.

The standard code of
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End sub
Works good for one copy.

I would like to do something like this:
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text1"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text2"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
end sub

I do keep getting error "SelectRecord" command isn't available.

Do I have to set focus back to the form??

Any ideas on how this can be done. Thank you for all your help.

Darren


I'm not sure that you have to set focus back to the form. I haven't
tried anything like this but as long as you can refer to the textbox
you can change it's value. Take out the setfocus lines and see what
happens.

I originally did not have the setfocus and I would get an error
telling me that I could not change the textbox properties since it did
not have the focus. That is the main reason I used the setfocus
command. I would prefer not having to set the focus but I thought
that it was neccessary.

Thank you
Darren


There's probably an issue with opening a report and referring to an open
form. If I was doing this I would probably just modify the recordsource
each time and then print.

Nov 13 '05 #4

P: n/a
dd******@yahoo.com (Darren DeCoste) wrote in message news:<73**************************@posting.google. com>...
"Deano" <de*********@hotmail.com> wrote in message news:<41***********************@ptn-nntp-reader03.plus.net>...
Darren DeCoste wrote:
I have an access project with a Form that has a Command button to
print the current record. I would like to Print the record 3 times,
changing a text field on each print.

The standard code of
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End sub
Works good for one copy.

I would like to do something like this:
private sub printbutton_click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text1"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

textbox.setfocus
textbox.text = "change text2"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
end sub

I do keep getting error "SelectRecord" command isn't available.

Do I have to set focus back to the form??

Any ideas on how this can be done. Thank you for all your help.

Darren


I'm not sure that you have to set focus back to the form. I haven't tried
anything like this but as long as you can refer to the textbox you can
change it's value. Take out the setfocus lines and see what happens.

I originally did not have the setfocus and I would get an error
telling me that I could not change the textbox properties since it did
not have the focus. That is the main reason I used the setfocus
command. I would prefer not having to set the focus but I thought
that it was neccessary.

Thank you
Darren


Deano, Thank you for your help.

I figured out the problem today.

I actually created one sub for the printing and the other sub tied to
the button. The one tied to the button called the one that did the
printing 3 seperate times. I also had to give the Form the focus
after updating the data. I ended up doing this:

One sub with the standard Form Print commands (PrintOne_Click) and the
other as: below

Call PrintOne_Click 'Prints the original

copytype.SetFocus
copytype.Text = "FILE"
copytype.ForeColor = 16744448
Form.SetFocus
Call PrintOne_Click ' Prints form with changed field both text and
color

copytype.SetFocus
copytype.Text = "ACCOUNTING/REP"
copytype.ForeColor = 32768
Form.SetFocus
Call PrintOne_Click ' Prints form with changed field both text and
color

copytype.SetFocus
copytype.Text = "ORIGINAL"
copytype.ForeColor = 255
Form.SetFocus ' Places the data back into the original state

This gives me 3 copies of the form with differnent labels for each
form.
It may not be the best coding technique but it gets the job done.
Thank you for the help

Darren
Nov 13 '05 #5

P: n/a
Deano, Thank you for your help.

I figured out the problem today.
<snipped>
This gives me 3 copies of the form with differnent labels for each
form.
It may not be the best coding technique but it gets the job done.
Thank you for the help


I know what you mean; you should see some of my coding :)
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.