Where am i going wrong here please?

sambase
07-21-2008, 04:02 AM
hi,

I am try to use ADO to get a collection of data from my database and place it into an msflexgrid. I used to be able to do it years ago but have not done any VB in a long while. Can someone please tell me where i am going wrong. I'm sure theres a lot of work needed on this code :).


Private Sub Command1_Click()
Dim MyConn As New ADODB.connection
Dim myRecSet As ADODB.Recordset
Dim query As Variant

MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=E:\Documents and Settings\Sam\Desktop\sams vb stuff\FLEX\stockfile.mdb"
MyConn.Open

query = "SELECT sName FROM Wines"
Set myRecSet = MyConn.Execute(query)
With MSFlexGrid1
.DataSource = query
MSFlexGrid1.Refresh
End With

End Sub


The error message i recieve is "Object required" and when debugging is highlights:



.DataSource = query



Any suggestions?

Thanks,

Sam

Flyguy
07-21-2008, 05:10 AM
The MSFlexGrid is not a databound control.
If you want the databound version you have to use the MSHFlexGrid control.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum