What is bad in this

A

alejandro

What i m doing wrong in this code i want to load a form with 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

Rick Brandt

alejandro said:
What i m doing wrong in this code i want to load a form with 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

Just apply the SQL string to the Form's RecordSource property (not
Recordset).
 
C

caimito

I am not an expert, but you are opening rsf before you
assign anything to the variable, and I think you need a
semicolon at the end of the SQL statement, inside the
quotation marks.
 

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

load a recordset 1
how to use recordset 1
SQL -- VBA 3
Problem with Do While 2
Type mismatch error. 1
Update syntax VBA and XML 2
Audit Trail Code 6
SQL - VBA once again 10

Top