Pass query results to form

G

Guest

My brain froze up on me...

What is the best way to pass a value from a SQL query back to my form?
I am doing a LookUp of a value in a table based on a couple of parameters
passed into the query. THis is a SQL statement passing to SQL server 2k and
only one record matches the criteria. THe SQL statement is fine (tested as a
pass-through). But I blanking on how to capture the output value and use that
in the form.
 
G

Guest

declare a variable
assign the variable your aquired value from your query
pass the value of the newly aquired variable to your object
such as a textbox:

Dim strMyVar As String
strMyVar = 'results from query
txtMyTextBox.setfocus
txtMyTextBox.text = strMyVar
 
G

Guest

Hey thanks, Sparker.
What is wrong with this syntax:
rst is properly declared and the query has a record. It just doesn't like
the second line.

Set rst = CurrentDb.OpenRecordset("rqTumStg")

Me.omg_ClinStage = rst.TumorStage

TIA,
Sam
 
S

Steve Schapel

Sam

Try with a ! instead of a . as in...
Me.omg_ClinStage = rst!TumorStage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top