S_W_Langdon
New Member
- Joined
- Feb 5, 2018
- Messages
- 13
Hi Everyone,
I have had a scan (search) through the posts but am unable to find something on this, so sorry if I missed it, or searched wrong...
I have an Access Database and am trying to pull information out of it into excel based on 2 dates within cells, now I can get it to pull the information from the Database, but it isn't pulling it correctly, instead of pulling all data between the 2 dates it is pulling everything (before, after, between)
Here is the code that I have setup (Var & Var1 are the reference cells)
If Sheet2.Range("AL2").Value = "Yes" Then
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate < #" & var1 & "#Then"
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate >= #" & var & "#"
Else
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate LIKE '" & var & "%" & "'"
End If
I have tried changing the <> on different rows to see if that helps, but it isn't working (am more used to Excel Formula I am afraid)
Any help people can give would be great
Thanks
I have had a scan (search) through the posts but am unable to find something on this, so sorry if I missed it, or searched wrong...
I have an Access Database and am trying to pull information out of it into excel based on 2 dates within cells, now I can get it to pull the information from the Database, but it isn't pulling it correctly, instead of pulling all data between the 2 dates it is pulling everything (before, after, between)
Here is the code that I have setup (Var & Var1 are the reference cells)
If Sheet2.Range("AL2").Value = "Yes" Then
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate < #" & var1 & "#Then"
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate >= #" & var & "#"
Else
SQL = "SELECT * FROM DatabaseTable WHERE StatusStartDate LIKE '" & var & "%" & "'"
End If
I have tried changing the <> on different rows to see if that helps, but it isn't working (am more used to Excel Formula I am afraid)
Any help people can give would be great
Thanks