|
-
Oct 27th, 2000, 11:20 AM
#1
Thread Starter
Junior Member
Everyone :
I'm trying to use flexgrid for the first time but I keep getting a "Object var or with block var not set" error on the datasource line. If I switch to a datagrid, this code works fine.
Dim objConn As ADODB.Connection
Dim objRS As ADODB.Recordset
Set objConn = New ADODB.Connection
Set objRS = New ADODB.Recordset
objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objConn.CursorLocation = adUseClient
objConn.ConnectionString = "Data Source=c:\applications\cumber\customerlist.mdb"
objConn.Open
sSQL = "select * from tblCustomer"
objRS.Source = sSQL
Set objRS.ActiveConnection = objConn
objRS.Open
<<<< Error on this line. >>>>>
Set grdCustomer.DataSource = objRS
Thanks for your help,
Dale Williams
-
Oct 27th, 2000, 12:47 PM
#2
Addicted Member
It seems that the grid has not got the right datasource. Its datasource should be a data control. So I think you should add a data control (i.e., an ADO Data Control), link the recordset with adodc1 and then set the grid. For example:
Set grdCustomer.DataSource = adodc1
But I am not sure of that. I only guess from you code.
-
Oct 27th, 2000, 12:59 PM
#3
Lively Member
Here is what Microsoft says.....
Hi,
Here is what Microsoft tells about your problem.The thing is that you can't bound Flexgrid to ADO but you can bind a DBGrid.Read what Microsoft says below...Even if you take a ADODC control and try to bind it then it gives error..
Have a look at what Microsoft says....
------------------------------------------------------------
Complex bound controls in previous versions of Visual Basic were bound to data sources with a mixture of DAO, RDO, and ODBC data sources. New complex bound Visual Basic controls, however, use ADO and OLEDB data sources, which are not internally compatible with the older data sources.
As a result, new complex bound controls (such as the Microsoft DataRepeater control or the Microsoft Hierarchical FlexGrid control) can be bound only to new data sources (ADO and OLEDB), and old complex bound controls can be bound only to older data sources. You can also use a Data Environment as a new OLEDB data source. If you attempt to bind a new complex bound control to an old data source or vice-versa, you get this error.
For a list of OLEDB-compatible components, click Components in the Project menu and look for "(OLEDB)" at the end of the name of the component.
------------------------------------------------------------
Sorry can't help in this....
-
Oct 27th, 2000, 03:40 PM
#4
Addicted Member
That's right. The correct control is a "Data" control. So the code should be:
Set grdCustomer.DataSource = data1
or set it manually with the mouse.
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
|