I need help urgent. I don't know how to filter a form with combobox By dates', cause I understood that the value of combobox should be a number, so what should I do if my values are dates? Please Help!
10 1933
Combo boxes are controls bound to queries. You should be able to go to the properties of the combo box and go to its control source and have it sort the date by descending value. That should sort the combo box for you.
Combo boxes don't have to be a number. But aside from that, Dates are stored as a number. So either way, no problem.
Check out (Example Filtering on a Form.) for the full information on this topic.
Thanks a lot.my problem was solved. I have another problem if you can help me. I am filtyering a form by few combo boxes by creating a long string from all the values of the combos. at the last combo I get a RunTimeError 2001:"You Cnceled previouse Operation". what's that mean?
Combo boxes don't have to be a number. But aside from that, Dates are stored as a number. So either way, no problem.
Thanks a lot.You was absoloute correct. my problem was solved. I have another problem if you can help me. I am filtering a form by few combo boxes by creating a long string from all the values of the combos. at the last combo I get a RunTimeError 2001:"You Cnceled previouse Operation". what's that mean?
NeoPa 32,556
Expert Mod 16PB
Perhaps you could post the code you use for this, just to give us a clue.
Perhaps you could post the code you use for this, just to give us a clue.
Thanks a lot.This is the Code: - Private Sub FilterProcessForm()
-
-
Dim strTotalFilter As String
-
Dim strMonthFilter As String
-
Dim strDepartmentFilter As String
-
Dim strProjectTypeFilter As String
-
Dim strCustomerFilter As String
-
Dim strProjectFilter As String
-
Dim strInvoiceFilter As String
-
-
'--------MonthFilter
-
If IsNull(Trim(cmbSearchByProcessMonth.Value)) Then
-
ShowMessegeBox "לא נרשם תאריך חוקי"
-
Exit Sub
-
End If
-
strMonthFilter = "fldmpsProcessMonth =" & "#" & cmbSearchByProcessMonth.Value & "#"
-
-
'--------DepartmentFilter
-
If cmbSearchByDepartment.Value = -999 Or IsNull(Trim(cmbSearchByDepartment.Value)) Then
-
strDepartmentFilter = ""
-
Else
-
strDepartmentFilter = "flddipDepartmentCode=" & cmbSearchByDepartment.Value & " AND "
-
End If
-
-
-
'--------ProjectTypeFilter
-
If cmbSearchByProjectTypeCode.Value = -999 Or IsNull(Trim(cmbSearchByProjectTypeCode.Value)) Then
-
strProjectTypeFilter = ""
-
Else
-
strProjectTypeFilter = "flddipProjectTypeCode=" & cmbSearchByProjectTypeCode.Value & " AND "
-
End If
-
-
-
'--------CustomerFilter
-
If cmbSearchByCustomer.Value = -999 Or IsNull(Trim(cmbSearchByCustomer.Value)) Then
-
strCustomerFilter = ""
-
Else
-
strCustomerFilter = "fldcicCustInternaCode=" & cmbSearchByCustomer.Value & " AND "
-
End If
-
-
'--------ProjectFilter
-
If cmbSearchByProject.Value = -999 Or IsNull(Trim(cmbSearchByProject.Value)) Then
-
strProjectFilter = ""
-
Else
-
strProjectFilter = "fldmpsDepartmentProjectCode =" & cmbSearchByProject.Value & " AND "
-
End If
-
-
'--------InvoiceFilter
-
If cmbInvoiceNumber.Value = -10000 Or IsNull(Trim(cmbInvoiceNumber.Value)) Then
-
strInvoiceFilter = ""
-
Else
-
strInvoiceFilter = "fldmpsInvoiceNumber=" & cmbInvoiceNumber.Value & " AND "
-
End If
-
-
'--------TotalFilter
-
strTotalFilter = strDepartmentFilter & strProjectTypeFilter & strCustomerFilter & strProjectFilter & strInvoiceFilter & strMonthFilter
-
-
Me.Filter = strTotalFilter // Here I Get The Error.
-
Me.FilterOn = True
-
End Sub
-----------------------------------------------------------
I checked The "TotalFilter" and was no problem.?????????
NeoPa 32,556
Expert Mod 16PB
The code mainly seems fine to me if [fldmpsProcessMonth] is a Date/time field and all the other fields are numeric.
There is no point in saying IsNull(Trim()) as that is the same as IsNull().
I've done some minor tidy-ups for you but I haven't fixed anything fundamental as I don't have the field types yet.
What are the types of all the fields? - Private Sub FilterProcessForm()
-
-
Dim strTotalFilter As String
-
Dim strMonthFilter As String
-
Dim strDepartmentFilter As String
-
Dim strProjectTypeFilter As String
-
Dim strCustomerFilter As String
-
Dim strProjectFilter As String
-
Dim strInvoiceFilter As String
-
-
'--------MonthFilter
-
If IsNull(Me!cmbSearchByProcessMonth) Then
-
ShowMessegeBox "?? ???? ????? ????"
-
Exit Sub
-
End If
-
strMonthFilter = "fldmpsProcessMonth=" & "#" & Me!cmbSearchByProcessMonth & "#"
-
-
'--------DepartmentFilter
-
If Me!cmbSearchByDepartment = -999 Or IsNull(Me!cmbSearchByDepartment) Then
-
strDepartmentFilter = ""
-
Else
-
strDepartmentFilter = "flddipDepartmentCode=" & Me!cmbSearchByDepartment & " AND "
-
End If
-
-
-
'--------ProjectTypeFilter
-
If Me!cmbSearchByProjectTypeCode = -999 Or IsNull(Me!cmbSearchByProjectTypeCode) Then
-
strProjectTypeFilter = ""
-
Else
-
strProjectTypeFilter = "flddipProjectTypeCode=" & Me!cmbSearchByProjectTypeCode & " AND "
-
End If
-
-
-
'--------CustomerFilter
-
If Me!cmbSearchByCustomer = -999 Or IsNull(Me!cmbSearchByCustomer) Then
-
strCustomerFilter = ""
-
Else
-
strCustomerFilter = "fldcicCustInternaCode=" & Me!cmbSearchByCustomer & " AND "
-
End If
-
-
'--------ProjectFilter
-
If Me!cmbSearchByProject = -999 Or IsNull(Me!cmbSearchByProject) Then
-
strProjectFilter = ""
-
Else
-
strProjectFilter = "fldmpsDepartmentProjectCode=" & Me!cmbSearchByProject & " AND "
-
End If
-
-
'--------InvoiceFilter
-
If Me!cmbInvoiceNumber = -10000 Or IsNull(Me!cmbInvoiceNumber) Then
-
strInvoiceFilter = ""
-
Else
-
strInvoiceFilter = "fldmpsInvoiceNumber=" & Me!cmbInvoiceNumber & " AND "
-
End If
-
-
'--------TotalFilter
-
strTotalFilter = strDepartmentFilter & _
-
strProjectTypeFilter & _
-
strCustomerFilter & _
-
strProjectFilter & _
-
strInvoiceFilter & _
-
strMonthFilter
-
-
Me.Filter = strTotalFilter // Here I Get The Error.
-
Me.FilterOn = True
-
End Sub
Thanks a lot for your kind help.
All the variables are int, beside the ProcessMonth which is DateTime
It' s the third form I do with few combos that are filtering together the form' and never got such error. pls help.
NeoPa 32,556
Expert Mod 16PB
In that case try this : - Private Sub FilterProcessForm()
-
-
Dim strFilter As String
-
-
'--------MonthFilter
-
If IsNull(Me!cmbSearchByProcessMonth) Then
-
ShowMessegeBox "?? ???? ????? ????"
-
Exit Sub
-
End If
-
-
strFilter = "(fldmpsProcessMonth=" & _
-
Format(Me!cmbSearchByProcessMonth,'\#m/d/yyyy\#)')
-
-
'--------DepartmentFilter
-
If Nz(Me!cmbSearchByDepartment,-999) <> -999 Then _
-
strFilter = strFilter & " AND (" & _
-
"flddipDepartmentCode=" & Me!cmbSearchByDepartment & ")"
-
-
'--------ProjectTypeFilter
-
If Nz(Me!cmbSearchByProjectTypeCode,-999) = -999 Then _
-
strFilter = strFilter & " AND (" & _
-
"flddipProjectTypeCode=" & Me!cmbSearchByProjectTypeCode & ")"
-
-
'--------CustomerFilter
-
If Nz(Me!cmbSearchByCustomer,-999) <> -999 Then _
-
strFilter = strFilter & " AND (" & _
-
"fldcicCustInternaCode=" & Me!cmbSearchByCustomer & ")"
-
-
'--------ProjectFilter
-
If Nz(Me!cmbSearchByProject,-999) <> -999 Then _
-
strFilter = strFilter & " AND (" & _
-
"fldmpsDepartmentProjectCode=" & Me!cmbSearchByProject & ")"
-
-
'--------InvoiceFilter
-
If Nz(Me!cmbInvoiceNumber,-10000) <> -10000 Then _
-
strFilter = strFilter & " AND (" & _
-
"fldmpsInvoiceNumber=" & Me!cmbInvoiceNumber & ")"
-
-
-
Me.Filter = strFilter
-
Me.FilterOn = True
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Piet |
last post by:
Hello wxPythoneers.
I have a problem with a dialog box derived from wxFrame which has a
wxComboBox as main element. Depending on the entry selected from the
ComboBox, the dialog box will be...
|
by: jdph40 |
last post by:
I have a form in Access 97 on which I have an unbound list box filled
with our employees names from tblEmployees. When you select an
employee's name and click a button, the following code is run...
|
by: Nip |
last post by:
I am trying to make a database for my test participants. I have 10
participants and have a table with them called participants which
includes an auto number ID and then the participant number and...
|
by: my-wings |
last post by:
I think I've painted myself into a corner, and I'm hoping someone can help
me out.
I have a table of books (tblBooks), which includes a field (strPubName) for
Publisher Name and another field...
|
by: John Tyce |
last post by:
When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items.Add(string) or ComboBox.Items.Insert(0,string);
Either way, the new string does not show up in the...
|
by: Hazz |
last post by:
In this sample code of ownerdraw drawmode, why does the '(ComboBox) sender'
line of code need to be there in this event handler?
Isn't cboFont passed via the managed heap, not the stack, into this...
|
by: Brad |
last post by:
Hello all,
I am using a combobox and binding a dataview to the
control. The control displays dates from a database. I am
trying to figure out how to format the date information
coming from the...
|
by: Bill |
last post by:
I have a 200 record database that includes a date/time field,
AnnivDate, for a wedding anniversary. AnnivDate has nulls and some
incorrect year data. I have been creating the Access database...
|
by: MyWaterloo |
last post by:
'''''''''''''''''''''''''''''''''''''''''''
' The AfterUpdate event procedure used in '
' the Find Customer combo box search. '
'''''''''''''''''''''''''''''''''''''''''''
'Moves to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |