Help- Open recordset

  • Thread starter Thread starter drorm
  • Start date Start date
D

drorm

Guest
I am a new VBA Programmer in Access 2000. I am trying to open a recordset and I keep getting error messages. can someone help?. Here is the Syntex:
Private Sub Command9_Click()

Dim Form As String
Dim strSQL As String
Dim intCount As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Form=Forms![WTNS1]![BTN]

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryfill", OpenDynaset)

Do Until rs.EOF

strType = rs.Fields(0)
Debug.Print strType

rs.MoveNext

Loop

rs.Close

End Sub

I get error 3001 invalid Argument

Also, trying to replace the name of the query with strSQL= " SELECT WTN from WTNS WHERE BTN= " & FORM
It does not work either.

What is going on
 
I think I see your problem.

I don't think you can use a Query in the call. *Not sure though cause I've never tried it.*

I always prefer to use an SQL statement in my Open Recordset call. The SQL you wrote should be changed to :

strSQL="SELECT WTN from WTNS WHERE BTN= """ & Me.btn & """ ;"

You needed to add the semicolon to end the SQL string.

Regards.
Duane Barker
 

Users who are viewing this thread

Back
Top Bottom