Solved

Data1 problem

Posted on 1998-11-17
6
275 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now