Opening a report based on a value of a column of combo list.

R

randria

Hello,
I have 2 reports "vrpt1" and "vrpt3", I would like either of the reports to
open based on the value of column(4) of the query based combo.
here is my code
Private Sub VchTxt_AfterUpdate()
On Error GoTo Err_VchTxt_AfterUpdate

Dim stDocName As String
Dim stLinkCriteria As String
Dim i As Long

i = VchTxt.Column(4) ' this gives invalid use of Null error
stLinkCriteria = "[VoucherN0]=" & Me![VchTxt]

If i = 12 Or i = 9 Or i = 5 Then
stDocName = "vrpt1"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
Else
stDocName = "vrpt3"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If

Exit_VchTxt_AfterUpdate:
Exit Sub

Err_VchTxt_AfterUpdate:
MsgBox Err.Description
Resume Exit_VchTxt_AfterUpdate
End Sub

- The above code gives " Invalid use of Null" error.
- If write i= Nz(VchTxt.Column(4)) and run, the report "vrpt3" opens even
if the value of vchTxt.Column(4) is 12 or 9 or 5.

Thank you in advance
 

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