Hello everyone. i have a fom and subform (they are not linked).The subform has a date field named StartDate. i have a button on the form that when clicked will change the recordset of the subform to show StartDate of today. When i hit the command button, the subform becomes blank.Its driving me crazy.Here is my code: - Private Sub cmdToday_Click()
-
-
Dim sSQL As String
-
-
sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = Date()"
-
-
Forms!ViewCases![ViewCasesSubform].Form.RecordSource = sSQL
-
-
End Sub
9 4120
Hello everyone. i have a fom and subform (they are not linked).The subform has a date field named StartDate. i have a button on the form that when clicked will change the recordset of the subform to show StartDate of today. When i hit the command button, the subform becomes blank.Its driving me crazy.Here is my code: - Private Sub cmdToday_Click()
-
-
Dim sSQL As String
-
-
sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = Date()"
-
-
Forms!ViewCases![ViewCasesSubform].Form.RecordSource = sSQL
-
-
End Sub
Date() is an embedded function, that needs to be exposed as a parameter within the SQL string. Try the syntax this way. - sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = " & Date()
FishVal 2,653
Recognized Expert Specialist
Are you sure the query returns any records?
Did you run it in query builder?
NeoPa 32,569
Recognized Expert Moderator MVP
As pDog says, you need the RESULTS of the Date() function added to your SQL string (IE it is for VBA to resolve not for the SQL interpreter). However, as a date literal, it should also be enclosed in '#' characters and formatted in M/D/Y format for SQL (See Literal DateTimes and Their Delimiters (#).). - sSQL = "SELECT * " & _
-
"FROM QueryCases " & _
-
"WHERE [StartDate] = " & Format(Date(), '\#m/d/yyyy\#')
NeoPa 32,569
Recognized Expert Moderator MVP
Actually, I just ran some tests and, certainly for me, the SQL interpreter DOES resolve Date() correctly when done as you have done. This means it doesn't need to be treated as a literal (it still can be but shouldn't NEED to be). I can't see what's wrong with your SQL. Is it possible that the reference to the control is wrong (even then, why would it change at all if the reference were wrong)? Anyway, in case it helps, check out Referring to Items on a Sub-Form.
Thank you so much for your help. do you think you could look at my file. i couldnt attach it here, it is too large - the link is below. i would really appreciate it. www.imperialelevatorcorp.com/download/date.zip
I downloaded your file, but could not open it because I have Access 2000 and you must have Access 2003. Sorry.
NeoPa 32,569
Recognized Expert Moderator MVP
If you leave instructions as to where to look inside the database (You haven't referred to any query by name), and the db is 2003 & not 2007, then I'll have a look for you from home (when I get there of course). I'd rather not spend ages just hunting around for the relevant part of the database though.
Thanks guys i got it - here is the code: - Dim sSQL As String
-
Dim viewToday
-
viewToday = Format(Now(), "mm/dd/yyyy")
-
-
sSQL = "SELECT * FROM QueryCases WHERE QueryCases.StartDate = #" & viewToday & "#;"
-
Me![ViewCasesSubform].Form.RecordSource = sSQL
NeoPa 32,569
Recognized Expert Moderator MVP
You're welcome :)
And thanks for letting us know - you saved me a job later ;)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Robert Neville |
last post by:
I would like to add filter functionality to my database whether
through the Main form or the subform. This question may be
rudimentary, yet I have not less experience with filtering data
outside from queries. Let me just add that Allen Browne excellent
article about this subject may not apply to this scenario on an
elementary level. (Here's the link to the article; Filter a Form on a
Field in a Subform -...
|
by: Andante.in.Blue |
last post by:
Hi everyone! I was wondering if there is a away to use Access 97's
build in filter-by-form function but restrict its effect to just the
subform.
I have a parent form that shows the major divisions of the company,
and a subform that is linked so that it displays all the jobs within
the division in the parent form. I also want the ability to filter
the subform, so the users can pick out a bunch of common jobs easily.
I did this using a...
|
by: Colin |
last post by:
I created a macro that starts a filter on a query. The criteria in the
query is:
Like & "*"
The macro is initiated by pressing a command button on the form. This
works fine.
However, when this form becomes an unbound subform of another main
form, I'm prompted twice for the value of the filter (i.e. the group
name to enter). How can I stop the double prompt when my form is used
|
by: Dave Boyd |
last post by:
Hi,
I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the user enters the
last qualifying field on the main form.
In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous...
|
by: dhowell |
last post by:
In reading some of the posts on this group, it appears as though it is
not strait forward at all to filter a form, which has subforms, by
criteria which are either on subforms or span more than one
subform.....
This MSDN article however makes it sound as simple as clicking "Filter
by Form", entering the search criterial in the form and/or it's
subforms, then just clicking "Apply Filter"......
...
| |
by: bcreighton |
last post by:
I have created a bound subform on an unbound masterform linked together
with a common field (A store's identification number) using an unbound
combobox on the masterform and an invisible field on the subquery,
which filters for a particular store. The subform is in continuous
mode. So, what you see when you select a store is a list of all the
items that that have not been billed for. There is a simple yes no
field that filters out all...
|
by: Kurt |
last post by:
I have an unbound main form with an unbound subform.
frmProjects
fsubProjectList
Using combo boxes, the user can select several search criteria on
frmProjects and then click a command button. The command button passes
the criteria as a string to a query. A subform, which is based on this
query, shows the results of the search.
|
by: Anja |
last post by:
Hi everyone,
I have a sub form that references a query to get the results. However,
what I want to do is filter the results further based on a certain
criteria. How can I tell the sub form to filter results based on a
certain criteria.
I tried using the Filter and OrderBy fields in the designer but they
seem to have no affect!
|
by: Barb.Richards |
last post by:
I have created an append query that pulls information from one
database, and will append the selected information into a new table.
The fields are setup like 'number' 'category' 'code' 'shares' and
'dollars'. Using the "backend" of this table I can filter the numbers
by right clicking and using Filter For: then enter 1 or 2 or 3 and
this will return results for all information that has 1 or 2 or 3 as a
number.
However, the problem I...
|
by: Matthew Wells |
last post by:
Hi there.
I am a programmer for a living, but this problem has my whole team stumped.
I have a subform based on a query. I'm not using the
"LinkMaster/ChildFields" properties ( I have my reasons ). The ssbform's
query has a criteria for forms!masterform!Keyfield. This works fine on
open. I have an options group with two options - True or All. Selecting
True adds a filter to the subform's fitler property "Billed = True". That...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |