Solved IF condition not Print current record (1 Viewer)

smtazulislam

Member
Local time
Today, 22:03
Joined
Mar 27, 2020
Messages
806
Hello, Any help will appreciate.
this is my form
Capture1.JPG

I tried to print SN-2 into 72 Record Numbers, But its printing SN-1 Record numbers 32 with Cancellation Report.
Here is code :
Code:
Private Sub cmdPrint_Click()
On Error GoTo cmdPrint_Click_Err
Me.Requery
If IsNull(Me.txtEffectiveDate) Then
    MsgBox "Please select a valid record", vbOKOnly, "Data Required"
End If

If IsNull(Me.txtCancelDate) Then
    DoCmd.OpenReport "rptAllowanceCancelation", acViewPreview, "", "[AllowanceID] = " & Me!txtAllowanceID, acWindowNormal
    DoCmd.RunCommand acCmdPrint
    Debug.Print

ElseIf Not IsNull(Me.txtCancelDate ) Then
    DoCmd.OpenReport "rptAllowance", acViewPreview, "", "[AllowanceID] = " & Me!txtAllowanceID, acWindowNormal
    DoCmd.RunCommand acCmdPrint
    Debug.Print
End If

'Tried it also    
'If IsNull(Me.txtCancelDate ) And Me.Active = 1 Then
'    DoCmd.OpenReport "rptAllowance", acViewPreview, "", "[AllowanceID] = " & Me!txtAllowanceID, acWindowNormal
'    DoCmd.RunCommand acCmdPrint
'    Debug.Print
'
'ElseIf Not IsNull(Me.txtCancelDate) And Me.Active = -1 Then
'    DoCmd.OpenReport "rptAllowanceCancelation", acViewPreview, "", "[AllowanceID] = " & Me!txtAllowanceID, acWindowNormal
'    DoCmd.RunCommand acCmdPrint
'    Debug.Print
'
'End If
    
cmdPrint_Click_Exit:
    Exit Sub

cmdPrint_Click_Err:
    MsgBox Error$
    Resume cmdPrint_Click_Exit
End Sub
 

bob fitz

AWF VIP
Local time
Today, 20:03
Joined
May 23, 2011
Messages
4,727
I believe that after you requery, the focus is set to the first record.
 

Users who are viewing this thread

Top Bottom