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

getting table data

Status
Not open for further replies.

gimpie1941

IS-IT--Management
Jan 1, 2003
6
US
I need to extract a selected record from a table (not source in form) and extract a field value which I want to set equal to a public variable.
any help?
Thanks Jim
 
gimpie1941

Sure. You can use DAO or ADO coding, or run an SQL statement with the DoCmd.RunSQL function to grab your information.

If this answer is too much of an overview, and if you provide more details, "we" can provide more meat in the answer.

Richard
 
Yes, I can do a Docmd.runsql to get the data, but I then need to put the data into a public variable. If I run a Docmd.runsql "select" how do I put the result into a variable?
Jim
SOrry for appearing stupid, but this is vexing...
 
How are ya gimipe1941 . . . .

You can do it with a recordset as follows:

Dim db as database, rst as Recordset
Set db=currentdb()
Set rst=db.OpenRecordset("Your Query",dbOpendynaset)
YourPublicVariable=rst!YourFieldOfInterest

The above assumes you query is setup to return the single record of interest. If not, you'll have to use the FindFirst method to set the record pointer to your record of interest.
 
Thank you, AceMan..

That is exactly what I was looking for.

Hope I can contribute someday.
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top