3 Replies - 907 Views - Last Post: 07 April 2013 - 09:19 AM Rate Topic: -----

#1 madujr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-July 12

How to use vb6 text boxes as parameters for date range in access query

Posted 03 April 2013 - 04:59 AM

Hi everyone,
Allow me to explain my situation below:
I have 2 textboxes in vb6 namely txtStartDate and txtEndDate.
I want these textboxes to hold starting date and ending date values respectively as parameters in Access date range query. I have a problem in expressing these textbox parameters in SQL statement within VB6.

Here's what I have so far:
Private Sub Command1_Click()
    salesForm.Adodc1.RecordSource = "SELECT * FROM Sales_Table WHERE (Between (Date_Sold = '" & txtStartDate.Text & "')  AND (Date_Sold = '" & txtEndDate.Text & "')) "
    salesForm.Adodc1.Refresh
End Sub



I get this error message when running the code above:
Syntax Error(Missing Operator)in query expression

Obviously, it has something to do with my sql statement.
I would appreciate any help I could get.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: How to use vb6 text boxes as parameters for date range in access query

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: How to use vb6 text boxes as parameters for date range in access query

Posted 03 April 2013 - 05:38 AM

Where and what have you been researching and looking?
A certain search engine provides me with a lot of results.
SQL Between and Access SQL Between
Was This Post Helpful? 0
  • +
  • -

#3 madujr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-July 12

Re: How to use vb6 text boxes as parameters for date range in access query

Posted 03 April 2013 - 06:18 AM

Hi,
Thanks for responding.
Can you tell me what is wrong with my statement?
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: How to use vb6 text boxes as parameters for date range in access query

Posted 07 April 2013 - 09:19 AM

Well, you're missing the operator! The error couldn't be more clear; you just don't understand the syntax of the SQL BETWEEN operator. Maybe you didn't look it up? Suppose you do. Clearly you haven't googled "Access SQL between dates" either. I suggest you do that as well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1