Connecting Tech Pros Worldwide Help | Site Map

cancel if no records

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 05:17 PM
David B
Guest
 
Posts: n/a
Default cancel if no records

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


  #2  
Old November 12th, 2005, 05:17 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: cancel if no records

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" <david@marleycotenospam.fsnet.co.uk> wrote in message
news:bsk87n$9r7$1@newsg2.svr.pol.co.uk...[color=blue]
> I have the following routine behind a button which prints invoices. I[/color]
want to[color=blue]
> cancel the routine if the first query ("invsendinvdetail") is returning[/color]
no[color=blue]
> 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
>[/color]


  #3  
Old November 12th, 2005, 05:18 PM
David B
Guest
 
Posts: n/a
Default Re: cancel if no records

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 <AllenBrowne@SeeSig.Invalid> wrote in message
news:3fedb629$0$1729$5a62ac22@freenews.iinet.net.a u...[color=blue]
> 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" <david@marleycotenospam.fsnet.co.uk> wrote in message
> news:bsk87n$9r7$1@newsg2.svr.pol.co.uk...[color=green]
> > I have the following routine behind a button which prints invoices. I[/color]
> want to[color=green]
> > cancel the routine if the first query ("invsendinvdetail") is returning[/color]
> no[color=green]
> > 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
> >[/color]
>
>[/color]

  #4  
Old November 12th, 2005, 05:18 PM
Arno R
Guest
 
Posts: n/a
Default Re: cancel if no records

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

--
Hope this helps
Arno R


"David B" <david@marleycotenospam.fsnet.co.uk> schreef in bericht
news:bsm7rf$p74$1@news7.svr.pol.co.uk...[color=blue]
> 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 <AllenBrowne@SeeSig.Invalid> wrote in message
> news:3fedb629$0$1729$5a62ac22@freenews.iinet.net.a u...[color=green]
> > 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" <david@marleycotenospam.fsnet.co.uk> wrote in message
> > news:bsk87n$9r7$1@newsg2.svr.pol.co.uk...[color=darkred]
> > > I have the following routine behind a button which prints invoices. I[/color]
> > want to[color=darkred]
> > > cancel the routine if the first query ("invsendinvdetail") is returning[/color]
> > no[color=darkred]
> > > 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
> > >[/color]
> >
> >[/color]
>[/color]


  #5  
Old November 12th, 2005, 05:18 PM
David B
Guest
 
Posts: n/a
Default Re: cancel if no records

Yep thats done the trick.
Thanks
DB

Arno R <arracomn_o_s_p_a_m@tiscali.nl> wrote in message
news:3feeabcc$0$41752$5fc3050@dreader2.news.tiscal i.nl...[color=blue]
> David,
> Check for records first:
> If DCount("*","YourFirstQueryName") = 0 then Exit Sub
>
> --
> Hope this helps
> Arno R
>
>
> "David B" <david@marleycotenospam.fsnet.co.uk> schreef in bericht
> news:bsm7rf$p74$1@news7.svr.pol.co.uk...[color=green]
> > 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 <AllenBrowne@SeeSig.Invalid> wrote in message
> > news:3fedb629$0$1729$5a62ac22@freenews.iinet.net.a u...[color=darkred]
> > > 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" <david@marleycotenospam.fsnet.co.uk> wrote in message
> > > news:bsk87n$9r7$1@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[/color][/color][/color]
returning[color=blue][color=green][color=darkred]
> > > 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
> > > >
> > >
> > >[/color]
> >[/color]
>
>[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.