Solved

Data1 problem

Posted on 1998-11-17
6
282 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:TheQ111798
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1497696
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
 

Author Comment

by:TheQ111798
ID: 1497697
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
 

Author Comment

by:TheQ111798
ID: 1497698
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
Stefaan earned 50 total points
ID: 1497699
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
 
LVL 12

Expert Comment

by:mark2150
ID: 1497700
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
 

Author Comment

by:TheQ111798
ID: 1497701
Forest for the trees.....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question