C
clearwave
I am trying to write code in Access VBA. I am going to run a select SQL to
read a record from a table then copy it into a variable. I am using
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strSQL As String
Dim strTmp As String
Dim rst As DAO.Recordset
Dim myDb As DAO.Database
Dim intResult As Integer
strSQL = "select FirmID as firmid" & _
"from Firm " & _
"where Firm.[Firm Name] = 'Credit Suisse' "
'"where Firm.[Firm Name]= Me.dealerName and " & _
'"Firm.[Vendor Name] = Me.vendorName"
Set myDb = currentDb()
Set rst = myDb.OpenRecordset(strSQL, DAO.dbOpenSnapshot)
End Sub
But for some reason, it always gives me run time error 91 Object variable or
with block variable not set.
How can I do that? What I want is simple, it is just query a record and copy
it into a variable.
Many thanks
read a record from a table then copy it into a variable. I am using
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strSQL As String
Dim strTmp As String
Dim rst As DAO.Recordset
Dim myDb As DAO.Database
Dim intResult As Integer
strSQL = "select FirmID as firmid" & _
"from Firm " & _
"where Firm.[Firm Name] = 'Credit Suisse' "
'"where Firm.[Firm Name]= Me.dealerName and " & _
'"Firm.[Vendor Name] = Me.vendorName"
Set myDb = currentDb()
Set rst = myDb.OpenRecordset(strSQL, DAO.dbOpenSnapshot)
End Sub
But for some reason, it always gives me run time error 91 Object variable or
with block variable not set.
How can I do that? What I want is simple, it is just query a record and copy
it into a variable.
Many thanks