473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

Nov 12 '05 #1
4 1762
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alexander van Meerten | last post by:
Hello, I have to make an application that works on pc and apple mac. Therefore I am investigating if it's possible to use html/javascript. The database has 10000 records and is sequentially...
4
by: Deano | last post by:
Alot of my forms are bound. I would like to offer a Cancel option so that they can make as many changes as they like and still Cancel out without making any changes. I have one idea of how to...
6
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in...
3
by: pmud | last post by:
Hi, I have an ASP.NET application using C# code. I am using a datagrid to display records from a database based on a user input, i.e a user enters a compnay name in text box & when he clicks a...
2
by: Bob | last post by:
In a winform with a datagridview using cellvalidating event but also have a save button that is located on a tablebindignnavigator. The behaviour I observe is that if the cellvalidating issues a...
1
by: Richard | last post by:
A shipment of material is received. The shipment contains several items. Each item is assigned an internal tracking number for auditing purposes and further processed. The tracking number is...
4
by: martin | last post by:
Hello, Is there a way to make a kind of "cancel" button on a form? Suppose you accidently changed or overwrote some data in a form, then I'd like to leave this form at once and cancel any...
1
by: Afshar | last post by:
hi everybody there, i want to cancel inserting records on specific circumstance based on a validation using ObjectDataSource's Inserting event. but need a Cancel() method to rollback record...
8
by: jmarcrum | last post by:
Hello all, i have a continuous form that displays about 1000 records and opens when I click a button. When the form opens, the user has the option of checking a checkbox that is located beside...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.