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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time Error '91' 1

Status
Not open for further replies.

TheLaughingMan

Programmer
Jan 20, 2011
2
GB
Hi, iv put some code into a project im working on, the code is for a flex grid.

all code seems fine and compiles okay, but i keep getting a runtime error when i click the flexgrid.

Run-time Error '91'

Object variable or With block variable not set.


Heres the code

[VB]
Private Sub GetBundles(ProductCode)
Dim Cols As Integer
Dim Rows As Integer
Dim cnn As Connection
Dim Columns
Dim CurrentColHead As Integer
Dim InsertCtrlPoints(10)
Dim Bundles As Recordset

Set cnn = CurrentProject.AccessConnection


Cols = 2
With grdWIPBundles
.Clear
.Cols = Cols
.Row = 2
.FixedRows = 1
.FixedCols = 1
.ColWidth(0) = 155
.RowHeight(0) = 300
.FocusRect = flexFocusHeavy
.SelectionMode = flexSelectionFree

.Row = 0

col_ix = 1
.TextArray(col_ix) = "Bundle No."
.ColWidth(col_ix) = 2000
.ColAlignment(col_ix) = flexAlignLeftCenter

Bundles.Open "SELECT * FROM Vw_Tk_Bundles" 'Debug here
While Not Bundles.EOF
.AddItem vbTab & Bundles!BundleNum
Bundles.MoveNext
Wend
Bundles.Close
.RowHeight(1) = 0
End With
cnn.Close
End Sub

[/VB]

If anyone has any ideas please let me know!

Thanks :)

 
Bundles is a not yet instantiated recordset.
I'd try something like this:
Set Bundles = New Recordset
Bundles.Open "SELECT * FROM Vw_Tk_Bundles", cnn

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
okay, did as you suggested to receive another Debug, had received this previous, but only happens once or twice so did not think much of it!

Run-time '3709'

The connection cannot be used to perform this operation. it is neither closed or invalid in the context.


i had clearly defined the connection at the beginning, and don't close it until the end. and iv used hundreds of connections like these with no trouble :s

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top