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

Need Simple Help on procedure

P: n/a
Below is a simple procedure, but I am new to this.
I need to add an error check that sees if there is they accidently push this
button when they have not made an invoice.
The check should be something like IF ME!ID1 <1 then End Sub and return

WHAT I HAVE:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub

Thanks
JC
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try inserting this line before the RunCommand line:

If IsNull(Me!ID1) Then Exit Sub

"JC Mugs" <jc****@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
Below is a simple procedure, but I am new to this.
I need to add an error check that sees if there is they accidently push this button when they have not made an invoice.
The check should be something like IF ME!ID1 <1 then End Sub and return

WHAT I HAVE:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub

Thanks
JC

Nov 12 '05 #2

P: n/a
On Sat, 17 Jan 2004 11:09:39 -0600, "JC Mugs" <jc****@hotmail.com>
wrote:

Try this:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
if Me!ID1 < 1 then
msgbox "No way I'll let you print this bad invoice!"
else
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
end if
End Sub

-Tom.

Below is a simple procedure, but I am new to this.
I need to add an error check that sees if there is they accidently push this
button when they have not made an invoice.
The check should be something like IF ME!ID1 <1 then End Sub and return

WHAT I HAVE:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub

Thanks
JC


Nov 12 '05 #3

P: n/a
THANKS that is what I needed!

"Scott McDaniel" <scott@NO___Spam--thedatabaseplace.net> wrote in message
news:6u********************@comcast.com...
Try inserting this line before the RunCommand line:

If IsNull(Me!ID1) Then Exit Sub

"JC Mugs" <jc****@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
Below is a simple procedure, but I am new to this.
I need to add an error check that sees if there is they accidently push

this
button when they have not made an invoice.
The check should be something like IF ME!ID1 <1 then End Sub and return

WHAT I HAVE:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub

Thanks
JC


Nov 12 '05 #4

P: n/a
JC Mugs wrote:
Below is a simple procedure, but I am new to this.
I need to add an error check that sees if there is they accidently push this
button when they have not made an invoice.
The check should be something like IF ME!ID1 <1 then End Sub and return

WHAT I HAVE:
Private Sub PrintInvoice_Click()

RunCommand acCmdSaveRecord
Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub

Thanks
JC


Private Sub PrintInvoice_Click()
On Error Goto Err_PrintInvoice_Click

'verify the ID is not null and greater than 0
If NZ(Me.ID1,0) > 0 then
'force a save if dirty. Calls Before/AfterUpdate form event
If Me.Dirty then RunCommand acCmdSaveRecord

Dim strDocName As String
Dim strWhere As String
strDocName = " rptInvoiceRec"
strWhere = "[ID1]=" & Me!ID1
DoCmd.OpenReport strDocName, acPrint, , strWhere
else
msgbox "Please create an invoice."
endif

Err_PrintInvoice_Click:
Exit Sub

Err_PrintInvoice_Click
'if there is NoData when the report is called (nodata event cancel =
True)....or
'if your BeforeUpdate event canceled the save, 2501 is returned.
'only display error if not 2501
If err.number <> 2501 then msgbox Err.description
resume Exit_PrintInvoice_Click
End Sub
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.