Pass query results to form

S

smk23

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.
 
S

sparker

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
 
S

smk23

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
 
Top