R
randria
Hello, I m posting this again because I received an error msg after sending
my first msg.
I have 2 reports "vrpt1" and "vrpt2" , and a combo "vchTxt" that has a
dropdown list of voucher numbers. After the user select a value from the
list, I want access to check the value a column(4) and if the value is 12 or
9 or 5 then vrpt1 should open else vrpt2. Running my code at the moment , it
opens only vrpt2 . Can someone help please.
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
What is wrong with my code ?
thank you in advance.
my first msg.
I have 2 reports "vrpt1" and "vrpt2" , and a combo "vchTxt" that has a
dropdown list of voucher numbers. After the user select a value from the
list, I want access to check the value a column(4) and if the value is 12 or
9 or 5 then vrpt1 should open else vrpt2. Running my code at the moment , it
opens only vrpt2 . Can someone help please.
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
What is wrong with my code ?
thank you in advance.