473,386 Members | 1,679 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,386 software developers and data experts.

Form Filter doesn't work for all data

47
Hi
I have a strange problem in a form filter my set up is as follows
there is a form named "InAlarmResumeForm" that has a subform "AlmActiveQrySform" the form has Textboxes with datapicker enabled "StartDate" and "EndDate" for the user to pick dates to apply to the subform filter.
the way this works is , if the user pick a date in the "StartDate" TextBox and left empty the "EndDate", the filter looks for register with the "StartDate" as its date if the user fill the "StartDate" and "EndDate" TextBoxes the filter will bring data between 2 dates, it seems to work . . but reviewing all the data I have in the query where the Subform is based , I can see data from dates between 12/09/11 to 15/09/11 ,and using the form filters I can make it works only for dates from 13/09/11 to 15/09/11, if I pick a single date from 06/09 to 12/09 the form returs zero records
If I use the 2 date boxes with dates in this range (06/09 to 12/09) the form returns data from the 09/09 to the high limt I set on the End date
If I choose the end date in the "suspected" range it will return zero records

here is the code for the Button that trigger the filter
Expand|Select|Wrap|Line Numbers
  1. Private Sub DateSearchBTn_Click()
  2. Dim DateFilter As String
  3. If Me.EndDate = "" Then _
  4. DateFilter = "([AlmDate]=#" & Me.StartDate & "#)"
  5. Form_AlmActiveQrySform.Filter = DateFilter
  6. Form_AlmActiveQrySform.FilterOn = True
  7. Debug.Print DateFilter
  8. If Me.EndDate <> "" Then
  9. DateFilter = "([AlmDate] Between #" & Me.StartDate & "# And #" & Me.EndDate & "#)"
  10. Form_AlmActiveQrySform.Filter = DateFilter
  11. Form_AlmActiveQrySform.FilterOn = True
  12. Debug.Print DateFilter
also here is the code from the query where the form is based
Expand|Select|Wrap|Line Numbers
  1. SELECT ALARMHISTORY.Al_Start_Time, CInt(Nz((Sum(DateDiff("n",[Al_start_Time],[Al_norm_Time]))),0)) AS AlmActiveTime, Format([Al_Start_Time],"dd/mm/yyyy") AS AlmDate, Format((Right([Al_Start_Time],13)),"Short Time") AS AlmTime, ALARMHISTORY.Al_Tag, ALARMHISTORY.Al_Norm_Time
  2. FROM ALARMHISTORY
  3. GROUP BY ALARMHISTORY.Al_Start_Time, Format([Al_Start_Time],"dd/mm/yyyy"), Format((Right([Al_Start_Time],13)),"Short Time"), ALARMHISTORY.Al_Tag, ALARMHISTORY.Al_Norm_Time
  4. HAVING (((ALARMHISTORY.Al_Norm_Time) Is Not Null));
The AlmDate field wich is the one I'm filtering in the Query comes from a timestamp field [Al_Start_Time] that is formated as dd/mm/yyyy hh:nn:ss

hope some body can help

Best regards

Raymundo Walle
Sep 17 '11 #1
3 2840
ADezii
8,834 Expert 8TB
Try:
Expand|Select|Wrap|Line Numbers
  1. Dim DateFilter As String
  2.  
  3. If Me.EndDate = "" Then
  4.   DateFilter = "([AlmDate]=#" & Me.StartDate & "#)"
  5. Else
  6.   DateFilter = "([AlmDate] Between #" & Me.StartDate & "# And #" & Me.EndDate & "#)"
  7. End If
  8.  
  9. With Form_AlmActiveQrySform
  10.   .Filter = DateFilter
  11.   .FilterOn = True
  12. End With
Sep 17 '11 #2
NeoPa
32,556 Expert Mod 16PB
Controls never resolve to "". If there is no data entered then the control will be Null.

SQL dates are not in local format but in specific SQL Date format (See Literal DateTimes and Their Delimiters (#)).
Sep 26 '11 #3
rwalle
47
Thanks for the Answers ,
I think it is related with the date format what I did is before put dates in filters I formated them using
Expand|Select|Wrap|Line Numbers
  1. Format([AlmDate],"mm/dd/yyyy")
also did the same for the Field [Al_Start_Time] so both the field to search and the search box date are in the same format

Thanks
Oct 13 '11 #4

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

Similar topics

5
by: Google Mike | last post by:
I have RH9 Linux with the versions of Apache and PHP that came with it. The PHP is version 4.2.2 on the CD, I believe. Apache, I think, is version 2.0. I found I can do some regular PHP stuff...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
2
by: lmeng | last post by:
Hi, I am new to this Forum. Thanks in advance for any kind help. In the following HTML code, when I change the value of one text field then click "Modify" button, if the validation fails a...
2
by: Larry | last post by:
I have made a form class, it is an about box. the form (the form class) resides in a project where I call it from a test form. Everything works ok. But, When I copy the form class (frmabout.vb...
2
by: Brett Porter | last post by:
Hi, I have many, many forms that use all of the different form validation controls. These work great on my local server however I have just been alerted to the fact that the form validation...
2
by: alan_atwood | last post by:
Hello all. I am having a problem with the submit() method that is driving me nuts. I'm using document.form.submit() with large text fields (approx. 2000 characters) and am getting a "Invalid...
6
by: MLH | last post by:
I don't always get what I want when I invoke the following Me!MySubFormControl.Refresh from code running in the main form. Am I doing something wrong here? Someone suggested that I open the...
5
by: moho | last post by:
Hi I'm trying to load a form into a div (that's hidden and then set to visible) = the form gets a page and stores it inside. I activate it by pressing a button. Then the div will fill in some...
1
by: VMI | last post by:
I have a Windows Form and, for its BackgroundImage, I put an all-white bitmap (opened mspaint, and immediately saved as bmp). Then I set the TransparencyKey property to White (I also added it in...
26
by: liams | last post by:
Hi, I recently learned how to use AJAX, but I'm having a problem with it. What I'm trying to do is validate a form with PHP, and write the output of the validation in the same page. From the last...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.