sa*******@msn.com (Samuel) wrote in message news:<53**************************@posting.google. com>...
Hello!
I'm using Access and I'm trying to write VBA code to get the value of
a specific field from a query.
I want to use this value to set a variable in my VBA code...
How can I do this????
Thanxs...
Samuel
Homework?
Dim strSQL As String
dim varWhatever As Variant
Dim rstReadTheManual As DAO.Recordset
strSQL = "SELECT MyField FROM MyTable;"
Set rstReadTheManual = CurrentDB.OpenRecordset(strSQL, dbOpenSnapshot)
With rstReadTheManual
If (.Recordcount > 0) Then
varWhatever = !MyField
Else
MsgBox "Oops! No records!"
End If
End With
Good luck when it gets really tricky.
Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk