R
randria
I have 2 reports, "vrpt1" and "vrpt2". I have a combo "vchTxt" that has a
dropdown list of Voucher numbers. After the user selects a value from the
list, I want access to check the value of column(4) and if that value is 12
or 9 or 5 then vrpt1 should open, else vrpt2. Can someone help me to check
what is wrong with my code because, it opens only vrpt2 even if column(4) is
12 or 9 or 5 ?
Private Sub VchTxt_AfterUpdate()
On Error GoTo Err_VchTxt_AfterUpdate
Dim stDocName As String
Dim stLinkCriteria As String
Dim i As Long
stLinkCriteria = "[VoucherN0]=" & Me![VchTxt]
i = Nz(Me.VchTxt.Column(4), 0) 'If I remove nz() then it gives error
"Invalid use of null"
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
dropdown list of Voucher numbers. After the user selects a value from the
list, I want access to check the value of column(4) and if that value is 12
or 9 or 5 then vrpt1 should open, else vrpt2. Can someone help me to check
what is wrong with my code because, it opens only vrpt2 even if column(4) is
12 or 9 or 5 ?
Private Sub VchTxt_AfterUpdate()
On Error GoTo Err_VchTxt_AfterUpdate
Dim stDocName As String
Dim stLinkCriteria As String
Dim i As Long
stLinkCriteria = "[VoucherN0]=" & Me![VchTxt]
i = Nz(Me.VchTxt.Column(4), 0) 'If I remove nz() then it gives error
"Invalid use of null"
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