Z
Zoe
I have a listbox that I want to be able to filter by several different
fields. I have combo boxes for Vendor and Status fields that are working
great. I also have two date fields (Check Date, Invoice Date) that I am
filtering by and that is also working. The last 2 fields I want to filter by
are CheckAmount & InvoiceNumber. I can't seem to get it to work. Here is some
information:
Form listbox is on is not bound.
ListInvoices is my listbox (recordsource is qryInvoice)
FiltInvNum is unbound txt box for Invoice Number
FiltCheckAmount is unbound txt box for Check Amount
Here is an example of what I have for code behind a button to filter by
Check Number:
Dim iFilterCheckNumber As String
If IsNull(FiltCheckNum) Then
MsgBox ("Please provide a check number to filter by.")
Else
iFilterCheckNumber = FiltCheckNum 'value from unbound check number field
Me.ListInvoices.RowSource = "SELECT qryInvoice.Address1,
qryInvoice.OccupantName, qryInvoice.VendorName, qryInvoice.InvoiceNumber,
qryInvoice.InvoiceDate, qryInvoice.AmountApproved, qryInvoice.InvoiceStatus,
qryInvoice.CheckNumber, qryInvoice.CheckDate, qryInvoice.Requester,
qryInvoice.RequestType, qryInvoice.InvoiceID FROM qryInvoice WHERE
qryInvoice.CheckNumber = " & iFilterCheckNumber
End If
For the field I filtered by date I had this:
Const conDateFormat = "\#mm\/dd\/yyyy\#"
and then at the end of the Me.ListInvoices.RowSource line I have this:
WHERE qryInvoice.CheckDate = " & Format(iFilterCheckDate, conDateFormat)
Do I have to do something similar to my CheckNumber & CheckAmount code to
define a currency format? I am at a loss. Help much appreciated! Hope I gave
you enough info.
Thanks!
fields. I have combo boxes for Vendor and Status fields that are working
great. I also have two date fields (Check Date, Invoice Date) that I am
filtering by and that is also working. The last 2 fields I want to filter by
are CheckAmount & InvoiceNumber. I can't seem to get it to work. Here is some
information:
Form listbox is on is not bound.
ListInvoices is my listbox (recordsource is qryInvoice)
FiltInvNum is unbound txt box for Invoice Number
FiltCheckAmount is unbound txt box for Check Amount
Here is an example of what I have for code behind a button to filter by
Check Number:
Dim iFilterCheckNumber As String
If IsNull(FiltCheckNum) Then
MsgBox ("Please provide a check number to filter by.")
Else
iFilterCheckNumber = FiltCheckNum 'value from unbound check number field
Me.ListInvoices.RowSource = "SELECT qryInvoice.Address1,
qryInvoice.OccupantName, qryInvoice.VendorName, qryInvoice.InvoiceNumber,
qryInvoice.InvoiceDate, qryInvoice.AmountApproved, qryInvoice.InvoiceStatus,
qryInvoice.CheckNumber, qryInvoice.CheckDate, qryInvoice.Requester,
qryInvoice.RequestType, qryInvoice.InvoiceID FROM qryInvoice WHERE
qryInvoice.CheckNumber = " & iFilterCheckNumber
End If
For the field I filtered by date I had this:
Const conDateFormat = "\#mm\/dd\/yyyy\#"
and then at the end of the Me.ListInvoices.RowSource line I have this:
WHERE qryInvoice.CheckDate = " & Format(iFilterCheckDate, conDateFormat)
Do I have to do something similar to my CheckNumber & CheckAmount code to
define a currency format? I am at a loss. Help much appreciated! Hope I gave
you enough info.
Thanks!