473,466 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Filter sub form by date

2 New Member
hi everyone,

i am trying to create a form which calls another form filtered according to the values in a text control and date control in the original form.
i am using this code to do so:
Expand|Select|Wrap|Line Numbers
  1. Private Sub GetTasks_Click()
  2.     Dim strForm As String     'Name of form to open.
  3.     Dim strAccField As String      'Name of the account field.
  4.     Dim strMonField As String      'Name of the month field.
  5.     Dim strHaving As String      'Where condition for OpenForm.
  6.     Const conDateFormat = "\#dd\/mm\/yyyy\#"
  7.  
  8.     strForm = "frmPlannedTasks"
  9.     strAccField = "account"
  10.     strMonField = "month"
  11.  
  12.     If Not IsNull(Me.Account) Then
  13.         If Not IsNull(Me.month) Then   'Both fields are filled.
  14.             strHaving = strAccField & " = '" & Me.Account & "' AND " & strMonField & " = " & Format(Me.month, conDateFormat)
  15.         End If
  16.     End If
  17.  
  18.     DoCmd.OpenForm strForm, acNormal, , strHaving
  19.  
  20. End Sub
The correct filter details do seem to be passed as in the Filter field of the sub-form i get the following:
account = 'Academy Class' AND month = #10/04/2007#
But the sub-form appears empty.

When i run the query the form is based on manually with the same filters i do get results.

(i am quite new to access and VB so let me know if i should be posting any other info.)

any ideas?

thanks, naomi
Jul 9 '07 #1
3 2218
kepston
97 Recognized Expert New Member
Hi Naomi
Change your date format:
Expand|Select|Wrap|Line Numbers
  1. Const conDateFormat = "\#mm\/dd\/yyyy\#"
Access seems to ignore your local settings sometimes.
Jul 9 '07 #2
academynaomi
2 New Member
OMG!! I've been fiddling with this for so long and that's all it was...!
Thank you so much for your help, you've saved me from going mad :-)
naomi
Jul 9 '07 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Hi Naomi
Change your date format:
Expand|Select|Wrap|Line Numbers
  1. Const conDateFormat = "\#mm\/dd\/yyyy\#"
Access seems to ignore your local settings sometimes.
This is not a reandom thing Kepston.
I suggest you may both find (Literal DateTimes and Their Delimiters (#).) interesting reading.
Jul 9 '07 #4

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

Similar topics

0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
3
by: Afton | last post by:
I would like to make a form that filters a report by Supervisor and by starting and ending date. I have the supervisors in a combo box, and that works. However, I do not know how to code to let...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
0
by: Stinky Pete | last post by:
Hi, The db I'm trying to update has a report form from which all other statistical forms and reports are selected/printed by dept, type, cost, number etc. The report form uses a date filter to...
6
by: fonzie | last post by:
Is there any way to include two unbound text boxes (for a start date and end date) to a filter-by-form? The users may want to filter by several different fields and they may want to include a date...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
9
by: dee | last post by:
I'd like to filter by the following criteria: left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767 I have no idea how to do this. Appreciate help.
1
by: Cara Murphy | last post by:
Hi There! Hoping you are able to help me with a filtering scenario: I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.