Hello folks!
I currently have a print button that will print a "invoice" (actually a report) when I click a button on my form for that particular record. Here is the code for that:
On Error GoTo Err_btnWorkOrder_Click
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.Newrecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "Work Order", acViewNormal, , strWhere
End If
Exit_btnWorkOrder_Click:
Exit Sub
Err_btnWorkOrder_Click:
MsgBox Err.Description
Resume Exit_btnWorkOrder_Click
But now I have three different reports, and I need the form to select one of the reports based on data entered on the form.
I have two fields on my form: cboStoreID and txtCharge. What I need to do, is this.
If the cboStoreID field starts with ME* (like ME004 or ME100, etc...) and regardless of what txtCharge is set to, always print report1
If cboStoreID field starts with anything else besides ME* (like U182 or W331, etc...) AND txtCharge = 0 then print report2
If cboStoreID field starts with anything else besides ME* (like U182 or W331, etc...) AND txtCharge > 0 then print report3
I was trying IF THEN statements but ran into trying to figure out how to have it check for the ME* vs anything else, as well as wondering if there was a better alternative than 3 different IF THEN statements.
thanks in advance everyone!
Richard
I currently have a print button that will print a "invoice" (actually a report) when I click a button on my form for that particular record. Here is the code for that:
On Error GoTo Err_btnWorkOrder_Click
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.Newrecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "Work Order", acViewNormal, , strWhere
End If
Exit_btnWorkOrder_Click:
Exit Sub
Err_btnWorkOrder_Click:
MsgBox Err.Description
Resume Exit_btnWorkOrder_Click
But now I have three different reports, and I need the form to select one of the reports based on data entered on the form.
I have two fields on my form: cboStoreID and txtCharge. What I need to do, is this.
If the cboStoreID field starts with ME* (like ME004 or ME100, etc...) and regardless of what txtCharge is set to, always print report1
If cboStoreID field starts with anything else besides ME* (like U182 or W331, etc...) AND txtCharge = 0 then print report2
If cboStoreID field starts with anything else besides ME* (like U182 or W331, etc...) AND txtCharge > 0 then print report3
I was trying IF THEN statements but ran into trying to figure out how to have it check for the ME* vs anything else, as well as wondering if there was a better alternative than 3 different IF THEN statements.
thanks in advance everyone!
Richard