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

cancel if no records

P: n/a
I have the following routine behind a button which prints invoices. I want to
cancel the routine if the first query ("invsendinvdetail") is returning no
records.

Grateful for suggestions as to how to do this
TIA
David B

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocname3 As String

stDocName1 = "invsendinvdetail"
stDocName2 = "appendinvtable"
stDocName = "invallreport"
stDocname3 = "appendinvnotodetail"

DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.OpenQuery stDocname3, acNormal, acEdit

DoCmd.OpenReport stDocName, acViewPreview
Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub

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


P: n/a
Cancel the NoData event of the report.

Then in your error handling ot the command button, ignore error 2501.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David B" <da***@marleycotenospam.fsnet.co.uk> wrote in message
news:bs**********@newsg2.svr.pol.co.uk...
I have the following routine behind a button which prints invoices. I want to cancel the routine if the first query ("invsendinvdetail") is returning no records.

Grateful for suggestions as to how to do this
TIA
David B

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocname3 As String

stDocName1 = "invsendinvdetail"
stDocName2 = "appendinvtable"
stDocName = "invallreport"
stDocname3 = "appendinvnotodetail"

DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.OpenQuery stDocname3, acNormal, acEdit

DoCmd.OpenReport stDocName, acViewPreview
Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub

Nov 12 '05 #2

P: n/a
Trouble is with doing it that way it carrys on and creates batch & invoice
numbers with no data to match.
I need to stop it at the first query if it is null.
David B
Allen Browne <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
Cancel the NoData event of the report.

Then in your error handling ot the command button, ignore error 2501.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David B" <da***@marleycotenospam.fsnet.co.uk> wrote in message
news:bs**********@newsg2.svr.pol.co.uk...
I have the following routine behind a button which prints invoices. I

want to
cancel the routine if the first query ("invsendinvdetail") is returning

no
records.

Grateful for suggestions as to how to do this
TIA
David B

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocname3 As String

stDocName1 = "invsendinvdetail"
stDocName2 = "appendinvtable"
stDocName = "invallreport"
stDocname3 = "appendinvnotodetail"

DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.OpenQuery stDocname3, acNormal, acEdit

DoCmd.OpenReport stDocName, acViewPreview
Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub



Nov 12 '05 #3

P: n/a
David,
Check for records first:
If DCount("*","YourFirstQueryName") = 0 then Exit Sub

--
Hope this helps
Arno R
"David B" <da***@marleycotenospam.fsnet.co.uk> schreef in bericht
news:bs**********@news7.svr.pol.co.uk...
Trouble is with doing it that way it carrys on and creates batch & invoice
numbers with no data to match.
I need to stop it at the first query if it is null.
David B
Allen Browne <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
Cancel the NoData event of the report.

Then in your error handling ot the command button, ignore error 2501.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David B" <da***@marleycotenospam.fsnet.co.uk> wrote in message
news:bs**********@newsg2.svr.pol.co.uk...
I have the following routine behind a button which prints invoices. I

want to
cancel the routine if the first query ("invsendinvdetail") is returning

no
records.

Grateful for suggestions as to how to do this
TIA
David B

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocname3 As String

stDocName1 = "invsendinvdetail"
stDocName2 = "appendinvtable"
stDocName = "invallreport"
stDocname3 = "appendinvnotodetail"

DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.OpenQuery stDocname3, acNormal, acEdit

DoCmd.OpenReport stDocName, acViewPreview
Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub


Nov 12 '05 #4

P: n/a
Yep thats done the trick.
Thanks
DB

Arno R <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
David,
Check for records first:
If DCount("*","YourFirstQueryName") = 0 then Exit Sub

--
Hope this helps
Arno R
"David B" <da***@marleycotenospam.fsnet.co.uk> schreef in bericht
news:bs**********@news7.svr.pol.co.uk...
Trouble is with doing it that way it carrys on and creates batch & invoice
numbers with no data to match.
I need to stop it at the first query if it is null.
David B
Allen Browne <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
Cancel the NoData event of the report.

Then in your error handling ot the command button, ignore error 2501.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David B" <da***@marleycotenospam.fsnet.co.uk> wrote in message
news:bs**********@newsg2.svr.pol.co.uk...
> I have the following routine behind a button which prints invoices. I
want to
> cancel the routine if the first query ("invsendinvdetail") is returning no
> records.
>
> Grateful for suggestions as to how to do this
> TIA
> David B
>
> Private Sub Command13_Click()
> On Error GoTo Err_Command13_Click
>
> Dim stDocName As String
> Dim stDocName1 As String
> Dim stDocName2 As String
> Dim stDocname3 As String
>
> stDocName1 = "invsendinvdetail"
> stDocName2 = "appendinvtable"
> stDocName = "invallreport"
> stDocname3 = "appendinvnotodetail"
>
> DoCmd.OpenQuery stDocName1, acNormal, acEdit
> DoCmd.OpenQuery stDocName2, acNormal, acEdit
> DoCmd.OpenQuery stDocname3, acNormal, acEdit
>
> DoCmd.OpenReport stDocName, acViewPreview
>
>
> Exit_Command13_Click:
> Exit Sub
>
> Err_Command13_Click:
> MsgBox Err.Description
> Resume Exit_Command13_Click
>
> End Sub
>



Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.