Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Subform printing report

Geek News

Subform printing report
sue gray 12/10/2008 9:11:04 PM
I have a subform that checks does some error checking in the Before UPdate
Event. I seem to have that working ok. What I want to be able to do now is
if the form passes all my error checks, I want to ask to print a report or
not? Also, If this is a new record will the report be blank? Do I have to
have some code to save the data, before printing. I'm not sure where to
start on this. THanks in advance
Re: Subform printing report
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/11/2008 4:00:40 AM
On Wed, 10 Dec 2008 13:11:04 -0800, sue gray
<suegray[ at ]discussions.microsoft.com> wrote:

Good question. Access provides for this as follows:
* In the Form_BeforeUpdate perform your checks like you are already
doing. If you detect an error condition, set the Cancel argument to
True. This will prevent the record from being saved, so the user can
fix it and try again. E.g.:
private sub Form_BeforeUpdate(Cancel as Boolean)
if Me.FirstName = "Tom" then
Msgbox "Yo! That's an illegal name. Fix it!"
Cancel = True
end if
end sub

Then to run a report or perform any other action that depends on the
record being valid and saved, use the Form_AfterUpdate event:
private sub Form_AfterUpdate
DoCmd.OpenReport "myReport", WhereCondition:="CustomerID=" &
Me.CustomerID
end sub

-Tom.
Microsoft Access MVP


[Quoted Text]
>I have a subform that checks does some error checking in the Before UPdate
>Event. I seem to have that working ok. What I want to be able to do now is
>if the form passes all my error checks, I want to ask to print a report or
>not? Also, If this is a new record will the report be blank? Do I have to
>have some code to save the data, before printing. I'm not sure where to
>start on this. THanks in advance
Re: Subform printing report
sue gray 12/11/2008 3:23:03 PM
Thanks for the response. Is there a way to ask the user if they want to
print the report or not? Thanks again.

"Tom van Stiphout" wrote:

[Quoted Text]
> On Wed, 10 Dec 2008 13:11:04 -0800, sue gray
> <suegray[ at ]discussions.microsoft.com> wrote:
>
> Good question. Access provides for this as follows:
> * In the Form_BeforeUpdate perform your checks like you are already
> doing. If you detect an error condition, set the Cancel argument to
> True. This will prevent the record from being saved, so the user can
> fix it and try again. E.g.:
> private sub Form_BeforeUpdate(Cancel as Boolean)
> if Me.FirstName = "Tom" then
> Msgbox "Yo! That's an illegal name. Fix it!"
> Cancel = True
> end if
> end sub
>
> Then to run a report or perform any other action that depends on the
> record being valid and saved, use the Form_AfterUpdate event:
> private sub Form_AfterUpdate
> DoCmd.OpenReport "myReport", WhereCondition:="CustomerID=" &
> Me.CustomerID
> end sub
>
> -Tom.
> Microsoft Access MVP
>
>
> >I have a subform that checks does some error checking in the Before UPdate
> >Event. I seem to have that working ok. What I want to be able to do now is
> >if the form passes all my error checks, I want to ask to print a report or
> >not? Also, If this is a new record will the report be blank? Do I have to
> >have some code to save the data, before printing. I'm not sure where to
> >start on this. THanks in advance
>
Re: Subform printing report
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/12/2008 3:21:51 AM
On Thu, 11 Dec 2008 07:23:03 -0800, sue gray
<suegray[ at ]discussions.microsoft.com> wrote:

Sure:
private sub Form_AfterUpdate
if Msgbox("Wanna see the report?", vbQuestion or vbYesNo) = vbYes then
DoCmd.OpenReport "myReport", WhereCondition:="CustomerID=" &
Me.CustomerID
end if
end sub

-Tom.
Microsoft Access MVP



[Quoted Text]
>Thanks for the response. Is there a way to ask the user if they want to
>print the report or not? Thanks again.
>
>"Tom van Stiphout" wrote:
>
>> On Wed, 10 Dec 2008 13:11:04 -0800, sue gray
>> <suegray[ at ]discussions.microsoft.com> wrote:
>>
>> Good question. Access provides for this as follows:
>> * In the Form_BeforeUpdate perform your checks like you are already
>> doing. If you detect an error condition, set the Cancel argument to
>> True. This will prevent the record from being saved, so the user can
>> fix it and try again. E.g.:
>> private sub Form_BeforeUpdate(Cancel as Boolean)
>> if Me.FirstName = "Tom" then
>> Msgbox "Yo! That's an illegal name. Fix it!"
>> Cancel = True
>> end if
>> end sub
>>
>> Then to run a report or perform any other action that depends on the
>> record being valid and saved, use the Form_AfterUpdate event:
>> private sub Form_AfterUpdate
>> DoCmd.OpenReport "myReport", WhereCondition:="CustomerID=" &
>> Me.CustomerID
>> end sub
>>
>> -Tom.
>> Microsoft Access MVP
>>
>>
>> >I have a subform that checks does some error checking in the Before UPdate
>> >Event. I seem to have that working ok. What I want to be able to do now is
>> >if the form passes all my error checks, I want to ask to print a report or
>> >not? Also, If this is a new record will the report be blank? Do I have to
>> >have some code to save the data, before printing. I'm not sure where to
>> >start on this. THanks in advance
>>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net