load a recordset

  • Thread starter Thread starter alejandro
  • Start date Start date
A

alejandro

What i m doing wrong in this code i want to load a form qirh a recordset but
something is wrong

Private Sub Form_Open(Cancel As Integer)

Dim rsf As Recordset
Dim ssql As String
ssql = "select * from product where code=1 "
rsf.Open
Set rsf = ssql
Form_individual.Recordset = rsf
rsf.Close


Thanks
Alejandro
 
May I suggest the following template:

Private Function MyFunc() As Boolean

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim fReturnValue As Boolean

On Error GoTo Proc_Err

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Select * from table")

If Not (rst.BOF And rst.EOF) Then
' Do some processing
End If

fReturnValue = True

Proc_Exit:
Set rst = Nothing
Set dbs = Nothing

MyFunc = fReturnValue
Exit Function

Proc_Err:
fReturnValue = False
Resume Proc_Exit

End Function


HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Back
Top