Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a form or dialogue box when the result is 0 or a minus

Status
Not open for further replies.

Mcnultyj

Technical User
Oct 2, 2001
2
GB
I have written a query to produce the result of two rows which have been subtracted from each other, what i want to do is display a form or dialogue when on the reults is a 0 or a minus figure

regards

James
 
Hi James,

This is how I do it. If i open a form based on (for example) a query, before displaying the form i will run the sql in code using DAO and if the recodset returns 0 rows then cancel opening the form.

Eg.

dim db as database
dim sSelect as string
dim rs as recordset

set db = currentdb
sSelect = "Select fields from table where etc etc"
' where sSelect is the exact SQL that your form is based.

set rs = db.openrecordset(sselect,dbopendynaset)
if rs.recordcount<1 then
' No records returned
docmd.openform &quot;form&quot;
else
docmd.openform &quot;other form&quot;
end if

I think this is the code. You may have to tweak it and correct any syntax problems.

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top