|
-
Feb 5th, 2002, 09:27 AM
#1
Thread Starter
Lively Member
Flexgrid DAO connection
I've just switched from using the data controls to using variables to link with Access. But with the data control I could easily setup the datasource property in designtime. But now, I can't seem to setup the link between the flexgrid and the database. Here's my code so far:
Code:
Public dbStats As Database
Public rsStats As Recordset
Set dbStats = OpenDatabase(App.Path & "\Stats.mdb")
SQL = "Select * From Day"
Set rsStats = dbStats.OpenRecordset(SQL, dbOpenDynaset)
FlexStatDay.DataSource = dbStats
But this gives the "Type Mismatch" error. I've also tried to use "Set FlexStatDay.DataSource = dbStats" but that gave me the "Object variable not set" error, and I've also replaced the dbStats with rsStats.
Can anyone help me out?
Dave.
-
Feb 5th, 2002, 09:44 AM
#2
Fanatic Member
It should be
Set FlexStatDay.DataSource = rsStats
The Object variable error might be due to confusion over dao or ado (maybe you have both checked as references?). Try declaring, As DAO.Recordset.
VB 6.0, Access, Sql server, Asp
-
Feb 5th, 2002, 09:53 AM
#3
Thread Starter
Lively Member
OK, here's my new code:
Code:
Private dbStats As Database
Private rsStats As DAO.Recordset
Set dbStats = OpenDatabase(App.Path & "\Stats.mdb")
SQL = "Select * From Day"
Set rsStats = dbStats.OpenRecordset(SQL, dbOpenDynaset)
Set FlexStatDay.DataSource = rsStats
But it still gives the same "Object variable not set" error. I've checked the references and only the DAO 3.6 reference is checked, no ADO.
Is there another solution?
Dave.
-
Feb 5th, 2002, 10:59 AM
#4
Fanatic Member
I suspect that it may not be possible with dao. I just found this in the help file:
datasource: An object reference that qualifies as a data source, including ADO Recordset objects, and classes or user controls defined as data sources (DataSourceBehavior property = vbDataSource).
(They don't mention dao recordsets, above) and:
Use the Set statement to set the DataSource property, as shown below:
Set Text1.DataSource = ADODC1
Two older controls, the Data control and RemoteData control, can be used as data sources, however you cannot set the DataSource property of another control or object to either of these controls at run time. For example, the following code will fail:
Set Text1.DataSource = Data1 ' Will fail! You can't set DataSource at
' run time to an intrinsic Data control.
To use either the Data control or RemoteData control as a data source, you can set the DataSource property of bound controls at design time only.
Well, they don't specifically mention MSFlexgrid. But I infer that the same limitation exists. I have no problem doing it at run time with ADO.
VB 6.0, Access, Sql server, Asp
-
Feb 5th, 2002, 03:09 PM
#5
Thread Starter
Lively Member
Hmmm, alright thanks... I think I'll go back to the data controls... Or learn ADO 
Dave.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|