load a recordset

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
 
R

RobFMS

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

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

how to use recordset 1
What is bad in this 2
recordset 2
do while? 1
Decimal places will not display 2
concatenating problem 2
Sumproduct Function 2
How to send email from Access without opening Outlook 4

Top