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]