What is bad in this

  • 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 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
 
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).
 
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.
 
Back
Top