Dte1 = >= Me!frmMainMenu.StartDate
Not sure if this correct or not! I'm trying to eliminate using Between start and end dates since it is not reliable.
Not sure if I needed to add to the end of the statement or not.
String Syntax
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
Code: Select all
Dim Dte1 As String 'Loads with frmMainMenu
Dim Dte2 As String
Dte1 = >= Me!frmMainMenu.StartDate
Dte2 = <= Me!frmMainMenu.EndDat
Between by itself is no good. Like Between start date and enddate since Access sees midnight as the cutoff you wont get a correct result.
Hence the need for a better way! Dteq=1 and Dte2 works fine thee way it was without >= or <=
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: String Syntax
Dte1 = >= Me!frmMainMenu.StartDate
Dte2 = <= Me!frmMainMenu.EndDat
makes no sense in VBA. Can you explain what you want to do?
Dte2 = <= Me!frmMainMenu.EndDat
makes no sense in VBA. Can you explain what you want to do?
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
I set the date variable when the frmMainMenu loads. It is and has been used in my databases. I then can enter into a qry or frm Between Dte1 and Dte2 for the date criteria. However, now I am using the time part of the date so I need to make sure that the syntax is correct.
I can no longer simply say Between start and end date in the qy or frm.
Since Dte1 and Dte2 are variables, I can use them. I select a startdate via a popup calendar on the form and it inputs it into the StartDate field
Same goes for EndDat, I can then filter my forms, reports or use as syntax in my queries.
I dont want to hard code anything since the dates change often.
I can no longer simply say Between start and end date in the qy or frm.
Since Dte1 and Dte2 are variables, I can use them. I select a startdate via a popup calendar on the form and it inputs it into the StartDate field
Same goes for EndDat, I can then filter my forms, reports or use as syntax in my queries.
I dont want to hard code anything since the dates change often.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
WkEndDate ' is a date field
Between [Dte1] and [Dte2]
Between [Dte1] and [Dte2]
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: String Syntax
That doesn't help. Please try to provide sufficient information.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
If I enter 3/2/2021 as the StartDate and 3/15/2021 as the EndDat and then run my report, query I need to make sure that it is allowing for the Date/Time since Access cuts off at midnight, I could use Between Start and EndDate in the query and get the wrong result.
If I use my Dte1 and Dte2 I want to make sure that does not happen. I am looking for the correct syntax for the StartDate and EndDat fields to pass into my qry,frm.rpt !
In other words, I need to adjust the 3/2/2021 (StartDate) & (EndDat) to #03/02/2021# so it wont cause any errors.
If I use my Dte1 and Dte2 I want to make sure that does not happen. I am looking for the correct syntax for the StartDate and EndDat fields to pass into my qry,frm.rpt !
In other words, I need to adjust the 3/2/2021 (StartDate) & (EndDat) to #03/02/2021# so it wont cause any errors.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: String Syntax
You'll need
>=Me!frmMainMenu.StartDate
and
<Me!frmMainMenu.EndDat+1
>=Me!frmMainMenu.StartDate
and
<Me!frmMainMenu.EndDat+1
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
I was experimenting with this, am I off? I think I would need to declare them individually?
Dim strDateFilter as String
strDateFilter = Between #" & Dte1 & "# And #" & Dte2 & "# "
Dim strDateFilter as String
strDateFilter = Between #" & Dte1 & "# And #" & Dte2 & "# "
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: String Syntax
You'll need something like
"[DateField]>=#" & Dte1 & "# And [DateField]<#" & Dte2 + 1 & "#"
"[DateField]>=#" & Dte1 & "# And [DateField]<#" & Dte2 + 1 & "#"
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: String Syntax
Many Thanks, sorry for the long way around.