473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Need Help About Combobox With Dates

16
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!
Feb 14 '07 #1
10 1933
maxamis4
295 Expert 100+
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.
Feb 14 '07 #2
Rabbit
12,516 Expert Mod 8TB
Combo boxes don't have to be a number. But aside from that, Dates are stored as a number. So either way, no problem.
Feb 14 '07 #3
NeoPa
32,556 Expert Mod 16PB
Check out (Example Filtering on a Form.) for the full information on this topic.
Feb 14 '07 #4
DanielM
16
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?
Feb 15 '07 #5
DanielM
16
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?
Feb 15 '07 #6
NeoPa
32,556 Expert Mod 16PB
Perhaps you could post the code you use for this, just to give us a clue.
Feb 15 '07 #7
DanielM
16
Perhaps you could post the code you use for this, just to give us a clue.
Thanks a lot.This is the Code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub FilterProcessForm()
  2.  
  3.     Dim strTotalFilter As String
  4.     Dim strMonthFilter As String
  5.     Dim strDepartmentFilter As String
  6.     Dim strProjectTypeFilter As String
  7.     Dim strCustomerFilter As String
  8.     Dim strProjectFilter As String
  9.     Dim strInvoiceFilter As String
  10.  
  11.     '--------MonthFilter
  12.     If IsNull(Trim(cmbSearchByProcessMonth.Value)) Then
  13.         ShowMessegeBox "לא נרשם תאריך חוקי"
  14.         Exit Sub
  15.     End If
  16.     strMonthFilter = "fldmpsProcessMonth =" & "#" & cmbSearchByProcessMonth.Value & "#"
  17.  
  18.     '--------DepartmentFilter
  19.     If cmbSearchByDepartment.Value = -999 Or IsNull(Trim(cmbSearchByDepartment.Value)) Then
  20.         strDepartmentFilter = ""
  21.     Else
  22.         strDepartmentFilter = "flddipDepartmentCode=" & cmbSearchByDepartment.Value & " AND "
  23.     End If
  24.  
  25.  
  26.     '--------ProjectTypeFilter
  27.     If cmbSearchByProjectTypeCode.Value = -999 Or IsNull(Trim(cmbSearchByProjectTypeCode.Value)) Then
  28.         strProjectTypeFilter = ""
  29.     Else
  30.         strProjectTypeFilter = "flddipProjectTypeCode=" & cmbSearchByProjectTypeCode.Value & " AND "
  31.     End If
  32.  
  33.  
  34.     '--------CustomerFilter
  35.     If cmbSearchByCustomer.Value = -999 Or IsNull(Trim(cmbSearchByCustomer.Value)) Then
  36.         strCustomerFilter = ""
  37.     Else
  38.         strCustomerFilter = "fldcicCustInternaCode=" & cmbSearchByCustomer.Value & " AND "
  39.     End If
  40.  
  41.      '--------ProjectFilter
  42.     If cmbSearchByProject.Value = -999 Or IsNull(Trim(cmbSearchByProject.Value)) Then
  43.         strProjectFilter = ""
  44.     Else
  45.         strProjectFilter = "fldmpsDepartmentProjectCode =" & cmbSearchByProject.Value & " AND "
  46.     End If
  47.  
  48.     '--------InvoiceFilter
  49.     If cmbInvoiceNumber.Value = -10000 Or IsNull(Trim(cmbInvoiceNumber.Value)) Then
  50.         strInvoiceFilter = ""
  51.     Else
  52.         strInvoiceFilter = "fldmpsInvoiceNumber=" & cmbInvoiceNumber.Value & " AND "
  53.     End If
  54.  
  55.     '--------TotalFilter
  56.     strTotalFilter = strDepartmentFilter & strProjectTypeFilter & strCustomerFilter & strProjectFilter & strInvoiceFilter & strMonthFilter
  57.  
  58.     Me.Filter = strTotalFilter  //   Here I Get The Error.
  59.     Me.FilterOn = True
  60. End Sub
-----------------------------------------------------------
I checked The "TotalFilter" and was no problem.?????????
Feb 15 '07 #8
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?
Expand|Select|Wrap|Line Numbers
  1. Private Sub FilterProcessForm()
  2.  
  3.     Dim strTotalFilter As String
  4.     Dim strMonthFilter As String
  5.     Dim strDepartmentFilter As String
  6.     Dim strProjectTypeFilter As String
  7.     Dim strCustomerFilter As String
  8.     Dim strProjectFilter As String
  9.     Dim strInvoiceFilter As String
  10.  
  11.     '--------MonthFilter
  12.     If IsNull(Me!cmbSearchByProcessMonth) Then
  13.         ShowMessegeBox "?? ???? ????? ????"
  14.         Exit Sub
  15.     End If
  16.     strMonthFilter = "fldmpsProcessMonth=" & "#" & Me!cmbSearchByProcessMonth & "#"
  17.  
  18.     '--------DepartmentFilter
  19.     If Me!cmbSearchByDepartment = -999 Or IsNull(Me!cmbSearchByDepartment) Then
  20.         strDepartmentFilter = ""
  21.     Else
  22.         strDepartmentFilter = "flddipDepartmentCode=" & Me!cmbSearchByDepartment & " AND "
  23.     End If
  24.  
  25.  
  26.     '--------ProjectTypeFilter
  27.     If Me!cmbSearchByProjectTypeCode = -999 Or IsNull(Me!cmbSearchByProjectTypeCode) Then
  28.         strProjectTypeFilter = ""
  29.     Else
  30.         strProjectTypeFilter = "flddipProjectTypeCode=" & Me!cmbSearchByProjectTypeCode & " AND "
  31.     End If
  32.  
  33.  
  34.     '--------CustomerFilter
  35.     If Me!cmbSearchByCustomer = -999 Or IsNull(Me!cmbSearchByCustomer) Then
  36.         strCustomerFilter = ""
  37.     Else
  38.         strCustomerFilter = "fldcicCustInternaCode=" & Me!cmbSearchByCustomer & " AND "
  39.     End If
  40.  
  41.      '--------ProjectFilter
  42.     If Me!cmbSearchByProject = -999 Or IsNull(Me!cmbSearchByProject) Then
  43.         strProjectFilter = ""
  44.     Else
  45.         strProjectFilter = "fldmpsDepartmentProjectCode=" & Me!cmbSearchByProject & " AND "
  46.     End If
  47.  
  48.     '--------InvoiceFilter
  49.     If Me!cmbInvoiceNumber = -10000 Or IsNull(Me!cmbInvoiceNumber) Then
  50.         strInvoiceFilter = ""
  51.     Else
  52.         strInvoiceFilter = "fldmpsInvoiceNumber=" & Me!cmbInvoiceNumber & " AND "
  53.     End If
  54.  
  55.     '--------TotalFilter
  56.     strTotalFilter = strDepartmentFilter & _
  57.                      strProjectTypeFilter & _
  58.                      strCustomerFilter & _
  59.                      strProjectFilter & _
  60.                      strInvoiceFilter & _
  61.                      strMonthFilter
  62.  
  63.     Me.Filter = strTotalFilter  //   Here I Get The Error.
  64.     Me.FilterOn = True
  65. End Sub
Feb 15 '07 #9
DanielM
16
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.
Feb 18 '07 #10
NeoPa
32,556 Expert Mod 16PB
In that case try this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub FilterProcessForm()
  2.  
  3.     Dim strFilter As String
  4.  
  5.     '--------MonthFilter
  6.     If IsNull(Me!cmbSearchByProcessMonth) Then
  7.         ShowMessegeBox "?? ???? ????? ????"
  8.         Exit Sub
  9.     End If
  10.  
  11.     strFilter = "(fldmpsProcessMonth=" & _
  12.                 Format(Me!cmbSearchByProcessMonth,'\#m/d/yyyy\#)')
  13.  
  14.     '--------DepartmentFilter
  15.     If Nz(Me!cmbSearchByDepartment,-999) <> -999 Then _
  16.         strFilter = strFilter & " AND (" & _
  17.                 "flddipDepartmentCode=" & Me!cmbSearchByDepartment & ")"
  18.  
  19.     '--------ProjectTypeFilter
  20.     If Nz(Me!cmbSearchByProjectTypeCode,-999) = -999 Then _
  21.         strFilter = strFilter & " AND (" & _
  22.                 "flddipProjectTypeCode=" & Me!cmbSearchByProjectTypeCode & ")"
  23.  
  24.     '--------CustomerFilter
  25.     If Nz(Me!cmbSearchByCustomer,-999) <> -999 Then _
  26.         strFilter = strFilter & " AND (" & _
  27.                 "fldcicCustInternaCode=" & Me!cmbSearchByCustomer & ")"
  28.  
  29.      '--------ProjectFilter
  30.     If Nz(Me!cmbSearchByProject,-999) <> -999 Then _
  31.         strFilter = strFilter & " AND (" & _
  32.                 "fldmpsDepartmentProjectCode=" & Me!cmbSearchByProject & ")"
  33.  
  34.     '--------InvoiceFilter
  35.     If Nz(Me!cmbInvoiceNumber,-10000) <> -10000 Then _
  36.         strFilter = strFilter & " AND (" & _
  37.                 "fldmpsInvoiceNumber=" & Me!cmbInvoiceNumber & ")"
  38.  
  39.  
  40.     Me.Filter = strFilter
  41.     Me.FilterOn = True
  42. End Sub
Feb 18 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
5
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...
4
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...
11
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...
2
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...
17
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...
1
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...
2
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...
6
by: MyWaterloo | last post by:
''''''''''''''''''''''''''''''''''''''''''' ' The AfterUpdate event procedure used in ' ' the Find Customer combo box search. ' ''''''''''''''''''''''''''''''''''''''''''' 'Moves to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.