Hi,
Im new to this whold VB code, and cannot figure out what im sure is a little snippet of code that will run a query, retrieve a single item, and display it in an edit box etc. on a report.
heres what ive been playing with (and various versions of it) :
Private Sub Report_Open(Cancel As Integer)
'Dim Total As String
Dim rs As New Recordset
'Set Q = CurrentDb.CreateQueryDef("")
'Q.SQL = "SELECT CP FROM Table1 WHERE Block = 3"
'Set rs = Q.OpenRecordset
Set rs = db.OpenRecordset( _
"SELECT CP FROM Table1 WHERE Block = 1", dbOpenDynaset)
End Sub
I have an edit box named TotalBlocks, and i had thought i could run the query, save it in a recordset and then assign that to the edit box.
Any help would be very much appreciated!
Thank you.
Im new to this whold VB code, and cannot figure out what im sure is a little snippet of code that will run a query, retrieve a single item, and display it in an edit box etc. on a report.
heres what ive been playing with (and various versions of it) :
Private Sub Report_Open(Cancel As Integer)
'Dim Total As String
Dim rs As New Recordset
'Set Q = CurrentDb.CreateQueryDef("")
'Q.SQL = "SELECT CP FROM Table1 WHERE Block = 3"
'Set rs = Q.OpenRecordset
Set rs = db.OpenRecordset( _
"SELECT CP FROM Table1 WHERE Block = 1", dbOpenDynaset)
End Sub
I have an edit box named TotalBlocks, and i had thought i could run the query, save it in a recordset and then assign that to the edit box.
Any help would be very much appreciated!
Thank you.