Connecting Tech Pros Worldwide Help | Site Map

cancel if no records

David B
Guest
 
Posts: n/a
#1: Nov 12 '05
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

Allen Browne
Guest
 
Posts: n/a
#2: Nov 12 '05

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]


David B
Guest
 
Posts: n/a
#3: Nov 12 '05

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]

Arno R
Guest
 
Posts: n/a
#4: Nov 12 '05

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]


David B
Guest
 
Posts: n/a
#5: Nov 12 '05

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]

Closed Thread