generating a query result

rnr1975

New member
Local time
Today, 16:59
Joined
Feb 9, 2006
Messages
7
I want to know how to generate a result from a query in a control of a form? For exampel I have made a SQL count function in a query and I want to use this result i a control of a form.
 
dim db as dao.database
dim rs as dao.recordset
dim str as string
str = "Your SQL String"
set rs=db.openrecordset(str,dbopensnapshot)
if rs.eof and rs.bof then
' no records exit exit sub
end if
'assuming you have one record
forms!YourformName!YourcontrolName = rs.fields(i) 'where i is the desired field number. Note fields are numbered 0 thru n.
rs.close
db.close
set rs=nothing
set db=nothing
 

Users who are viewing this thread

Back
Top Bottom