Connecting Tech Pros Worldwide Help | Site Map

Form Print with changed copies

Darren DeCoste
Guest
 
Posts: n/a
#1: Nov 13 '05
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
Deano
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Form Print with changed copies


Darren DeCoste wrote:[color=blue]
> 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[/color]

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.



Darren DeCoste
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Form Print with changed copies


"Deano" <deanma66999@hotmail.com> wrote in message news:<4125c948$0$37369$ed2619ec@ptn-nntp-reader03.plus.net>...[color=blue]
> Darren DeCoste wrote:[color=green]
> > 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[/color]
>
> 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.[/color]


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
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Form Print with changed copies


Darren DeCoste wrote:[color=blue]
> "Deano" <deanma66999@hotmail.com> wrote in message
> news:<4125c948$0$37369$ed2619ec@ptn-nntp-reader03.plus.net>...[color=green]
>> Darren DeCoste wrote:[color=darkred]
>>> 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[/color]
>>
>> 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.[/color]
>
>
> 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[/color]

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.



Darren DeCoste
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Form Print with changed copies


ddecost2@yahoo.com (Darren DeCoste) wrote in message news:<731937d3.0408200627.5ac765ea@posting.google. com>...[color=blue]
> "Deano" <deanma66999@hotmail.com> wrote in message news:<4125c948$0$37369$ed2619ec@ptn-nntp-reader03.plus.net>...[color=green]
> > Darren DeCoste wrote:[color=darkred]
> > > 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[/color]
> >
> > 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.[/color]
>
>
> 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[/color]

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
Deano
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Form Print with changed copies


[color=blue]
> Deano, Thank you for your help.
>
> I figured out the problem today.[/color]

<snipped>[color=blue]
>
> 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[/color]

I know what you mean; you should see some of my coding :)


Closed Thread