If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Data mismatch in SQL - report data environment

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-11, 12:48
Jero Jero is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
Post Data mismatch in SQL - report data environment

My SQL statement in source data of my VB^ report data environment works well to extract records between #05/30/2011# and #06/05/2011# in American format.

SELECT WBTkt, DLNo, DDate, DTimeIN,DTimeOUT, RegNo, EAmount
FROM WBBasE WHERE DDate BETWEEN #05/30/2011# AND #06/05/2011#
ORDER BY DDate, DTimeOUT

My problem is when I use a variable or input textbox name from the form (frmRpWBT), which calls the report I get, "Data type mismatch in criteria expression." Where am I going wrong?

Dim vrStDt as Date, vrEdDt as Date
-------------
vrStDt = CDATE(txtStDt.Text)
vrEdDt = CDATE(txtEdDt.Text)
---------
All my SQL alternative statements give the same error;
WHERE DDate BETWEEN ' & # & vrStDt & # & ' AND ' & # & vrEdDt & # & '
or WHERE DDate BETWEEN ' & # & Forms!frmRpWBT!txtStDt & # & ' AND ' & # & Forms!frmRpWBT!txtEdDt & # & '

Please assist?
Reply With Quote
  #2 (permalink)  
Old 07-21-11, 15:01
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
You're not including the "#" signs in your string:

example:
WHERE DDate BETWEEN ' & # & vrStDt & # & ' AND ' & # & vrEdDt & # & '

should be:
WHERE DDate BETWEEN #' & vrStDt & '# AND #' & vrEdDt & '# '


Where are you calling this from? To track this down in the future I would recommend setting a breakpoint in your code and examining the sql you ended up creating before you send it to the database. It makes funny quote issues like this easy to spot.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #3 (permalink)  
Old 07-25-11, 07:45
Jero Jero is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
Post Data Type Mismatch in SQL - report data environment

Thanks Teddy for your attention & response. Let me clarify your direction;
You wrote - should be:
WHERE DDate BETWEEN #' & vrStDt & '# AND #' & vrEdDt & '# '
Is the quote at the end of this statement relevant?
To respond to your query, "Where are you calling this from?" This is a SQL statement within the source of data of my report data environment (deWBTrns1b). I'm calling the report - rptWBTpdly from the form - frmRpWBT.
I also forgot to ask, how can I have these two dates appearing as from: & to: in my report?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On