Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
Does anyone know why I would get a run-time error 91 when using a MSFlexgrid. "Object Variable or with block variable not set.

heres my code below.

This code will work fine with a datagrid and a MSHFlexgrid
but not a MSFlexGrid. when I hit debug it highlites the .OPEN strRs, strCn

strRs = "SELECT wrkordno, orgdate, orgname, dept, status FROM WRKORD WHERE status = 'OPEN'"
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Open strRs, strCn
Set MSFlexGrid1.DataSource = rs
rs.MoveFirst
rccount = rs.RecordCount
lblOpenWO.Caption = rccount


Thanks DVannoy
A+,Network+,CNA
dvannoy@onyxes.com
 
OK, why do I dim that as new? that code works with everything else. is it just for when i am using the MSFlexGrid?

Thanks dvannoy@onyxes.com
 
Try putting the Setrs line before the SQL Statement, like this,

Set rs = New ADODB.Recordset
strRs = "SELECT wrkordno, orgdate, orgname, dept, status FROM WRKORD WHERE status = 'OPEN'"
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Open strRs, strCn
Set MSFlexGrid1.DataSource = rs
rs.MoveFirst
rccount = rs.RecordCount
lblOpenWO.Caption = rccount

I think what was happening was after your sql statement complteted, you were resetting your recordset, therefore there was no information from the select statement left. It had been reset.

Also check and make sure you have your strCn connection open when your statement executes. Rob
Just my $.02.
 
I can make it work with any other grid...just not this one.
Heres my entire code:

Private Sub Form_Load()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCn As String
Dim strRs As String

strCn = "driver={SQL Server};" & _
"server=server;uid=sa;pwd=;database=workorder"

Set cn = New ADODB.Connection

With cn
.ConnectionString = strCn
.Provider = "msdasql"
.ConnectionTimeout = 60
.Open strCn
End With

Set rs = New ADODB.Recordset
strRs = "SELECT wrkordno, orgdate, orgname, dept, status FROM WRKORD WHERE status = 'OPEN'"
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Open strRs, strCn
Set MSFlexGrid1.DataSource = rs
rs.MoveFirst
rccount = rs.RecordCount
lblOpenWO.Caption = rccount

I dont understand why it wont work dvannoy@onyxes.com
 
hi

Your problem lies in fact that u can not switch ur datasource for flexigrid at runtime using ADO.
if u must-- u should try DAO .
 
yep the recordset object is not recognised as a datasource for some reason I am having the same problem
 
you must have a data source control for the MSFlexGrid. see here for details :
The MSHFlexGrid does not require this data source. If the MSHFlexGrid is too slow around 10,000 lines ~ you need to buy a control like those from component one. The component one controlis expensive but has been able to handle lots of rows fast.
 
Hi!

I have that same problem. I have to use ado recordset, so control isn't option.

If I use MSHFlexGrid, can I get that working so that it won't show data hierachically? That would be anserw to my problem.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top