View Full Version : Can't Set RecordSet, Object Required


sambo
10-02-2002, 10:39 AM
What is wrong with this Sub Procedure?

Private Sub Form_Open(Cancel As Integer)
Dim whichSet As String
whichSet = "SELECT tblHistory.Comment, tblRma.SerialNum, tblRma.RmaID " & _
"FROM tblRma INNER JOIN tblHistory ON tblRma.RmaID = tblHistory.RmaID " & _
"WHERE (tblRma.SerialNum)=" & commentOpener.finalSerial '![Comment Form]![serialHolder]))"


Set Me.Recordset = whichSet

Call fillRecords(Me.Recordset, Me.SerialHolder)

End Sub

I am trying to resest the Recordset Dynamically upon entry to the form.

[commentOpener.finalSerial] is a global variable that I get from the function that calls the Form to Open.
I get the error "Object Required". Probably syntax w/ my Recordset statement.

glynch
10-02-2002, 11:15 AM
This is how I work with recordsets

Dim rstMyRecordset as Recordset
Dim dbsMyDatabase as Database
Dim whichSet As String

whichSet = "SELECT tblHistory.Comment, tblRma.SerialNum, tblRma.RmaID " & _
"FROM tblRma INNER JOIN tblHistory ON tblRma.RmaID = tblHistory.RmaID " & _
"WHERE (tblRma.SerialNum)=" & commentOpener.finalSerial '![Comment Form]![serialHolder]))"

Set dbsMyDatabase = CurrentDB
Set rstMyRecordset = dbsMyDatabase.OpenRecordset (whichSet)

Call fillRecords(rstMyRecordset, Me.SerialHolder)

End Sub

I don't know what you are doing inside of fillRecords, but I think I have plugged in some adjustments into your code that will get it to run (or at least a step closer).

Good Luck

sambo
10-02-2002, 12:16 PM
Thanks Glynch,
Your post helped me.
I also realized that I needed to also change my Record Source (not just my Record Set) for what I was doing.
I got it working now.