Plase find error in code

K

Kolas

I have built up a event procedure to select data from a table, criteria based
on 6 comboboxes and display data in a report.

Please helpme in finding error in the following code.
When i run, it promts
'Enter Parameter Value' for all comboboxes except first two.

Private Sub cmdApplyFilter_Click()
Dim strMaterial As String
Dim strDiameter As String
Dim strPressureTier As String
Dim strPipeType As String
Dim strStatus As String
Dim strPipeDigitised As String
Dim strFilter As String

'If a combo box is empty its value is Null so I can use an If Statement to
check whether or not the user made a choice and then construct the
appropriate SQL:

If SysCmd(acSysCmdGetObjectState, acReport, "rptPipe") <> acObjStateOpen
Then
MsgBox "You must open the report first."
Exit Sub
End If

If IsNull(Me.cboMaterial.Value) Then
strMaterial = "Like '*'"
Else
strMaterial = "='" & Me.cboMaterial.Value & "'"
End If



If IsNull(Me.cboDiameter.Value) Then
strDiameter = "Like '*'"
Else
strDiameter = "='" & Me.cboDiameter.Value & "'"
End If



If IsNull(Me.cboPressureTier.Value) Then
strPressureTier = "Like '*'"
Else
strPressureTier = "='" & Me.cboPressureTier.Value & "'"
End If



If IsNull(Me.cboPipeType.Value) Then
strPipeType = "Like '*'"
Else
strPipeType = "='" & Me.cboPipeType.Value & "'"
End If



If IsNull(Me.cboStatus.Value) Then
strStatus = "Like '*'"
Else
strStatus = "='" & Me.cboStatus.Value & "'"
End If



If IsNull(Me.cboPipeDigitised.Value) Then
strPipeDigitised = "Like '*'"
Else
strPipeDigitised = "='" & Me.cboPipeDigitised.Value & "'"
End If


strFilter = "[Material]" & strMaterial & "AND [Diameter]" & strDiameter
& "AND [PressureTier]" & strPressureTier & "AND [PressureTier]" &
strPressureTier & "AND [PipeType]" & strPipeType & "AND [Status]" & strStatus
& "AND [PipeDigitised]" & strPipeDigitised

With Reports![rptpipe]
.Filter = strFilter
.FilterOn = True
End With
End Sub
 
K

Klatuu

the problem will not be with your code. The prompt you are getting means the
row source queries for your combo boxes have criteria they can't understand.
Posting the SQL of the row source queries of those that are asking for a
paramenter value would be more useful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top