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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a Query and set a Feild on a unbound form

Status
Not open for further replies.

twsjd

Technical User
Sep 18, 2002
5
US
I am new to MS Access and I was wondering if their is a way to run a Query as a total query and put the result on a form that is not bound to a datasource. I would asume you use ADO but i am not sure how to do it.

Thanks
Jon
 
Hi

Since you mention ADO I assume you are on Access2000 or AccessXP, so the minimum code is:

Dim cn As ADO.Connection
Dim Rs as ADO.REcordset

Set cn = CurrentProject.Connection
Set Rs = NEW ADO.Connection
Rs.Open "SELECT ...etc your SQL here",cn
If Rs.RecordCount > 0 Then
txtControl = RS!ColumnName
End if
Rs.Close
Set Rs = Nothing
Set cn = Nothing

You need to use your own control/columnnames of course and theer are other parameters / seetings which you may wish to investigate (eg CursorLocation, and further parameters in the Rs.Open method

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top