Solved

Data1 problem

Posted on 1998-11-17
6
284 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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
Course of the Month3 days, 21 hours left to enroll

630 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