J
Janez Banez
What am I doing wrong in the next code? Using ADODB I am
opening a recordset of a table and with the subroutine I
am wanting to get the values of some fields. I have
defined first my own object (type) for the values of the
fields of one record.
Debuging I found out that the problem must be somehow in
transfering of the references of object variables rst and
vrst as arguments to the subroutine. Call statement cause
the error "Compile error: Object required". Please, help!
Janez
The code:
------------------------
Type tvrst
date1 As Date
num1 As Double
str1 As String
End Type
-------------------------
Public Function Main()
Dim rst As ADODB.Recordset
Dim vrst As tvrst
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.Source = "tblTable1"
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open
Call ReadTable(rst, vrst)
.....
End Function
-------------------------
Public Sub ReadTable(rst As ADODB.Recordset, vrst As tvrst)
vrst.date1 = rst.Fields("DATE1")
.....
End Sub
--------------------------
opening a recordset of a table and with the subroutine I
am wanting to get the values of some fields. I have
defined first my own object (type) for the values of the
fields of one record.
Debuging I found out that the problem must be somehow in
transfering of the references of object variables rst and
vrst as arguments to the subroutine. Call statement cause
the error "Compile error: Object required". Please, help!
Janez
The code:
------------------------
Type tvrst
date1 As Date
num1 As Double
str1 As String
End Type
-------------------------
Public Function Main()
Dim rst As ADODB.Recordset
Dim vrst As tvrst
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.Source = "tblTable1"
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open
Call ReadTable(rst, vrst)
.....
End Function
-------------------------
Public Sub ReadTable(rst As ADODB.Recordset, vrst As tvrst)
vrst.date1 = rst.Fields("DATE1")
.....
End Sub
--------------------------