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

Storing Variables From Open Rst 1

Status
Not open for further replies.

TheMus

Technical User
Aug 23, 2000
28
0
0
US
I'm trying to figure out how the recordset object works. How do you read through a recordset and capture variables? I have the rst open but I can't get anything to display.

Dim rstTemp As DAO.Recordset
Set rstTemp = CurrentDb.OpenRecordset("SELECT * FROM Agent WHERE [SITE]='GGTF'")
Dim vararray As Variant
rstTemp.MoveFirst
Set vararray = rstTemp.GetRows(1)
msgbox vararray
rstTemp.Close

My question is as cryptic as my code. Thanks for any help.

Rus
 
Try This Below. Just creat a new module and add the code there will be a play button on your tool bar in the VBA editor click that and you will get your desired results.

If you need more Help let me know. Keep In mind that this is just one way to acomplish this task.

Function GetMyRow()

Dim FieldNum As Integer
Dim FieldCount As Integer
Dim rstTemp As DAO.Recordset
Dim vararray As Variant

Set rstTemp = CurrentDb.OpenRecordset("SELECT * FROM Agent WHERE [SITE]='GGTF';")

FieldNum = 0
FieldCount = rstTemp.Fields.Count

rstTemp.MoveFirst
While Not rstTemp.EOF
While (FieldCount <> 0)
vararray = vararray & &quot;, &quot; & rstTemp.Fields(FieldNum).Value
FieldNum = FieldNum + 1
FieldCount = FieldCount - 1
Wend
rstTemp.MoveNext
Wend

MsgBox vararray
rstTemp.Close

End Function Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Thank you much Dave. I appreciate your help.

Rus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top