Parameter Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am trying to retreive values from a Query "abdulQuery" where the Location is the one which the user selects from the combo box "cmb_location" and date is the user selection from Calendar control "calrecon". The datatype for the field Location is text and for the field Entry_date is Dat

The following is the code
'connection already establishe
Dim qrySel1 As Strin
Dim rs6 As New ADODB.Recordse

qrySel1 = "SELECT abdulQuery.* from abdulQuery where abdul.Location='" & Trim(Me.cmb_location.Value) & "' and abdul.Entry_date = '" & (Me.calrecon.Value) & "'
Set rs6 = New ADODB.Recordse
rs6.Open qrySel1, con, adOpenKeyset, adLockOptimisti

The problem is when I try to execute it gives me error: "Datatype mismatch in criteria expression". Can anyone help me out?
 
Hi,
I am trying to retreive values from a Query "abdulQuery" where the Location is the one which the user selects from the combo box "cmb_location" and date is the user selection from Calendar control "calrecon". The datatype for the field Location is text and for the field Entry_date is Date

The following is the code:
'connection already established
Dim qrySel1 As String
Dim rs6 As New ADODB.Recordset

qrySel1 = "SELECT abdulQuery.* from abdulQuery where abdul.Location='" & Trim(Me.cmb_location.Value) & "' and abdul.Entry_date = '" & (Me.calrecon.Value) & "'"
Set rs6 = New ADODB.Recordset
rs6.Open qrySel1, con, adOpenKeyset, adLockOptimistic

The problem is when I try to execute it gives me error: "Datatype mismatch in criteria expression". Can anyone help me out?

Date/Time fields must be delimited by # rather than by ' - if
Entry_Date is a Date field, use

abdul.Entry_date = #" & (Me.calrecon) & "#"

Note also that the .value property is optional, since it's the
default.
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You've set up the query to read the criteria as strings. You have to
put the correct delimiters around the relevant data types.

Data type Delimiter Example
- --------- ----------- -------------
Date # #2/6/2004# <- m/d/yyyy
String ' 'this string'
Numeric <nothing> 123456


MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQCQZu4echKqOuFEgEQKzOwCgqSPyHHAKAwldskCEGaROJC+eGSkAoPoN
+7xlwSpM9ikiwmLHiONCMCJe
=d5vh
-----END PGP SIGNATURE-----
 
Hi Guys

Thanks for the help. It really worked. The problem as you people have explained; was with the delimeter. Thanks again.
 
Back
Top