Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data1 problem

Posted on 1998-11-17
6
Medium Priority
?
285 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Accepted Solution

by:
Stefaan earned 200 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

Industry Leaders: 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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