By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

data type mismatch in criteria expression

P: 27
Hello Everyone,

Could you help me to find out what is wrong with my query, please? The problem is on the [Date of Change] which is a Date field

Expand|Select|Wrap|Line Numbers
  1. Me.RecordSource = "SELECT tbl_GCDS_Operations_Positions_Fills_Log.* " & _
  2.        "From tbl_GCDS_Operations_Positions_Fills_Log " & _
  3.        "WHERE (((tbl_GCDS_Operations_Positions_Fills_Log.[Date of Change])='" & Me.cboDate.Column(0, Me.cboDate.ListIndex) & "')) " & _
  4.        "ORDER BY tbl_GCDS_Operations_Positions_Fills_Log.[Date of Change];"
  5.     Me.Requery
  6.  
  7.  
Thank you.
Apr 19 '18 #1

✓ answered by twinnyfo

Ivon,

Try changing line 3:

Expand|Select|Wrap|Line Numbers
  1. "WHERE (((tbl_GCDS_Operations_Positions_Fills_Log.[Date of Change])= #" & Me.cboDate.Column(0, Me.cboDate.ListIndex) & "#)) " & _
You had the WHERE statement looking for a text value. The "#" indicate a date is expected.

Hope this hepps!

Share this Question
Share on Google+
5 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,205
Ivon,

Try changing line 3:

Expand|Select|Wrap|Line Numbers
  1. "WHERE (((tbl_GCDS_Operations_Positions_Fills_Log.[Date of Change])= #" & Me.cboDate.Column(0, Me.cboDate.ListIndex) & "#)) " & _
You had the WHERE statement looking for a text value. The "#" indicate a date is expected.

Hope this hepps!
Apr 19 '18 #2

P: 27
You are awesome! Thank you.
Apr 19 '18 #3

twinnyfo
Expert Mod 2.5K+
P: 3,205
Any time! Glad to be of service!
Apr 19 '18 #4

NeoPa
Expert Mod 15k+
P: 31,419
Don't forget to explain to students that dates should never be used in SQL strings just as they come (See Literal DateTimes and Their Delimiters (#)). It will generally work in the USA, but nowhere else in the world.
Apr 20 '18 #5

twinnyfo
Expert Mod 2.5K+
P: 3,205
I meant to reference that article, but forgot. Thanks, NeoPa!
Apr 20 '18 #6

Post your reply

Sign in to post your reply or Sign up for a free account.