Hi -
Thanks to anyone who can help me figure this out.
I have an access database that was created long before my time. The users have a report that is selected between 2 dates. Now I need to add a parameter from the form (which I added on the screen) called acctltr. This is to select also select only the account numbers in the table InvoiceTable that end with whatever they put in the box. Really they are limited to "X" and "P X" at this time.
I am not very good with VBA so I am not sure how to add this into the code. The code is below. If there is a better way I am sure open to it because this code looks VERY confusing.
Thanks up front for any help!
Thanks to anyone who can help me figure this out.
I have an access database that was created long before my time. The users have a report that is selected between 2 dates. Now I need to add a parameter from the form (which I added on the screen) called acctltr. This is to select also select only the account numbers in the table InvoiceTable that end with whatever they put in the box. Really they are limited to "X" and "P X" at this time.
I am not very good with VBA so I am not sure how to add this into the code. The code is below. If there is a better way I am sure open to it because this code looks VERY confusing.
Thanks up front for any help!
Code:
Private Sub cmdprint_Click()
On Error GoTo exit_cmdprint
'mysql = "SELECT * from InvoiceTable " & _
' " WHERE ((not InvoiceTable.InvoicePrintDate1 Is Null) AND (not InvoiceTable.InvoicePrintDate2 Is Null) AND (InvoiceTable.InvoicePrintDate3 Is Null) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#))"
'Me.RecordSource = mysql
'If Me.Form.Recordset.RecordCount > 0 Then
' DoCmd.OpenReport "rptInvoiceSumReport", acViewPreview, , "((Not InvoiceTable.InvoicePrintDate1 Is Null) AND (Not InvoiceTable.InvoicePrintDate2 Is Null) AND (InvoiceTable.InvoicePrintDate3 Is Null) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#) and (not balancedue = 0))"
'End If
'mysql = "SELECT * from InvoiceTable " & _
' " WHERE ((not InvoiceTable.InvoicePrintDate1 Is Null) AND (InvoiceTable.InvoicePrintDate2 Is Null) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#))"
'Me.RecordSource = mysql
'If Me.Form.Recordset.RecordCount > 0 Then
' DoCmd.OpenReport "rptInvoiceSumReport", acViewPreview, , " ((not InvoiceTable.InvoicePrintDate1 is Null) AND (InvoiceTable.InvoicePrintDate2 is Null) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#) and (not balancedue = 0))"
'End If
mysql = "SELECT * from InvoiceTable " & _
" WHERE (InvoiceTable.InvoicePrintDate1 Is Null) AND (datevalue([InvoiceTable.InvoiceDate]) >= #" & dtefrom & "#) and (datevalue([InvoiceTable.InvoiceDate]) <= #" & dteto & "#)"
Me.Form.RecordSource = mysql
If Me.Form.Recordset.RecordCount > 0 Then
DoCmd.OpenReport "rptInvoiceSumReport", acViewPreview, , " ((InvoiceTable.InvoicePrintDate1 is Null) AND (Datevalue([InvoiceTable.InvoiceDate]) >= #" & dtefrom & "#) And (datevalue([InvoiceTable.InvoiceDate]) <= #" & dteto & "#))"
End If
'mysql = "SELECT * from InvoiceTable " & _
' " WHERE ((not InvoiceTable.InvoicePrintDate1 Is Null) AND (not InvoiceTable.InvoicePrintDate2 Is Null) AND (NOT InvoiceTable.InvoicePrintDate3 Is Null) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#) and (not balancedue = 0))"
'Me.RecordSource = mysql
'If Me.Form.Recordset.RecordCount > 0 Then
' DoCmd.OpenReport "rptInvoiceSumReport", acViewPreview, , " ((Not InvoiceTable.InvoicePrintDate1 Is Null) AND (Not InvoiceTable.InvoicePrintDate2 Is Null) AND (Not InvoiceTable.InvoicePrintDate3 Is Null)) AND (InvoiceTable.InvoiceDate Between #" & dtefrom & "# And #" & dteto & "#) and (not balancedue = 0)"
'End If
GoTo exit_normal
exit_cmdprint:
MsgBox (Err.Description)
exit_normal:
'Update_Invoice_PrintDate
'MsgBox (MyRecordSource)
End Sub