Data1 problem

Code:
Dim db As Database
Dim rs As Recordset
Dim sql As String
Dim Data1 As Data

Set ws = DBEngine.Workspaces(0)
sql = "Select * From employees"

Set db = ws.OpenDatabase("C:\MyDB\Nwind")
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
Set Data1.Recordset = rs

Question:
The "Set Data1.Recordset = rs" line comes back with an error
of variable or with block not set, but this matches what is in the msdn
TheQ111798Asked:
Who is Participating?
 
StefaanConnect With a Mentor Commented:
Hi,

If the Data1 control is already on your form, then you don't need to include it in your Dim statement.

Dim db As Database
Dim rs As Recordset
Dim sql As String

Set ws = DBEngine.Workspaces(0)
sql = "Select * From employees"

Set db = ws.OpenDatabase("C:\MyDB\Nwind")
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
Set Data1.Recordset = rs

This should do the trick.

0
 
mark2150Commented:
Umm, Data1 wants to be a control, not a variable. You've got it Dimmed as a data structure, this is not the same as the Data1 object.

M

0
 
TheQ111798Author Commented:
Yes Data1 is an object, but so is a textbox and I can still write
text1.text = "Hello", why can't I point the reference of the recordset property at the rs object variable.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
TheQ111798Author Commented:
Again, the original code I gave is right out of the msdn so there has to be some basis for how to make it work
0
 
mark2150Commented:
Stefaan is restating my point. You defined it with DIM and that conflicts with the control. Drop the DIM and the control should start working!

M

0
 
TheQ111798Author Commented:
Forest for the trees.....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.