Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Searching + Data Mining _ Docmd.applyfilter To SQL Linked Database Table

Posted by: marinko888 Feb 14 2020, 01:14 PM

Hi,
I am using this Filter for filtering data from a linked SQL database table:

DoCmd.ApplyFilter , "dbo_Session.[DatumStart] BETWEEN '" & Me.SessionStart & "' And '" & Me.SessionEnd & "'"

but I am getting an error:



TextBox Format is ShortDate and linked SQL Database Table Field Format is Date...

What is the problem here?

Thanks for your help!

Posted by: theDBguy Feb 14 2020, 01:19 PM

Hi. Just a guess, but unless it's a pass through query, the delimiter for dates in Access is the # character.

Posted by: marinko888 Feb 14 2020, 01:26 PM

It is the linked SQL Database Table so the delimiter is ' character...

Posted by: theDBguy Feb 14 2020, 01:35 PM

Hi. I understand that; but if you're executing the filter code in Access, then I think you'll have to use Access' language.

Posted by: marinko888 Feb 14 2020, 01:40 PM

I have already tried that without success.

Posted by: theDBguy Feb 14 2020, 02:33 PM

Hi. Sorry to hear that...

Posted by: cheekybuddha Feb 14 2020, 02:35 PM

Hi,

Try either:

CODE
  DoCmd.ApplyFilter , "dbo_Session.[DatumStart] BETWEEN '" & Format(Me.SessionStart, "yyyy-mm-dd hh:nn:ss") & "' And '" & Format(Me.SessionEnd, "yyyy-mm-dd hh:nn:ss") & "'"

Or:
CODE
  DoCmd.ApplyFilter , "dbo_Session.[DatumStart] BETWEEN #" & Format(Me.SessionStart, "yyyy-mm-dd hh:nn:ss") & "# And #" & Format(Me.SessionEnd, "yyyy-mm-dd hh:nn:ss") & "#"


hth,

d

Posted by: marinko888 Feb 14 2020, 05:28 PM

Thanks for helping me out with this one. This is finally working out!

Posted by: cheekybuddha Feb 15 2020, 03:55 AM

Hi, please share your working solution if you get the chance.