Script error any ideas

goju

Registered User.
Local time
Today, 12:55
Joined
Apr 7, 2005
Messages
77
last ever question, i need a long hloiday

it errors on: theId = ctl.Column(0, v)

Private Sub Monthly_MD_Report_Click()

'Run a report displaying only the records chosen
'by the user in the form's listbox.

Dim v As Variant
Dim Frm As Form
Dim ctl As Control
Dim theId As Long
Dim WhereCrit As String

'If nothing is selected, notify user...
If Me.List101.ItemsSelected.Count = 0 Then
MsgBox "Please select a month.", vbExclamation, "No Month Selected"
'and then scram.
Exit Sub
End If

'Assign form and control to object variables.
Set Frm = Forms!FrmForm
Set ctl = Frm!List101

'Begin building Where string.
WhereCrit = "Expr2"

'Add each selected item to the WHERE string.
For Each v In ctl.ItemsSelected
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'The first column in the list, holding SupplierID, is hidden.
'See the list's "Column Widths" and "Column Count" properties in
'its property dialog and look up the terms in Help for more info.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Coordinates: 1st column (0); row v
'where v changes for each round of the loop.
theId = ctl.Column(0, v)
'Tag on to string.
WhereCrit = WhereCrit & theId & " OR Expr2 "
Next v
'Loop ends; selected items are now accounted for...

'NOTE: To better understand what the code is doing, uncomment the
'next line to print the Where string to the Immediate window.
'Debug.Print WhereCrit

'Clean-up the Where string by removing the trailing text.
WhereCrit = Left(WhereCrit, Len(WhereCrit) - 17)

'Test (see note a few lines above).
'Debug.Print WhereCrit

'By default, the Suppliers Report returns all records from the Suppliers Table.
'Here the Suppliers Report is opened using the 'Where clause' to filter it down
'to only the items selected in the listbox.
DoCmd.OpenReport "MD Form", acViewPreview, , WhereCrit

End Sub
 
You really need to learn how to ask questions.

So you get an error on that statement. Which error? What does it say?
 
sorry it comes up run tome error 94 invalid use of null

it then highlights :theId = ctl.Column(0, v)

sorry ive been chucked in the deep end im drowning
 
The error means that you are getting a Null value in the control (which is odd for column(0) ). I would check the underlying data to see what is going on.

Peter
 
im way out of my depth, thanks trying
 

Users who are viewing this thread

Back
Top Bottom