Connecting Tech Pros Worldwide Help | Site Map

Data type mismatch in criteria expression.

Newbie
 
Join Date: Aug 2009
Posts: 4
#1: Aug 31 '09
Quote:
I get the error message "Data type mismatch in criteria expression" when running the coding(bold). So i am not sure what is going wrong. Thanks for helping.


Expand|Select|Wrap|Line Numbers
  1. Select Case (cbMonth.Text)
  2.             Case "January"
  3.  
  4.                 Dates = "1"
  5.  
  6.             Case "February"
  7.  
  8.                 Dates = "2"
  9.  
  10.             Case "March"
  11.  
  12.                 Dates = "3"
  13.  
  14.             Case "April"
  15.  
  16.                 Dates = "4"
  17.  
  18.             Case "May"
  19.  
  20.                 Dates = "5"
  21.  
  22.             Case "June"
  23.  
  24.                 Dates = "6"
  25.  
  26.             Case "July"
  27.  
  28.                 Dates = "7"
  29.  
  30.             Case "August"
  31.  
  32.                 Dates = "8"
  33.  
  34.             Case "September"
  35.  
  36.                 Dates = "9"
  37.  
  38.             Case "October"
  39.  
  40.                 Dates = "10"
  41.             Case "November"
  42.  
  43.                 Dates = "11"
  44.  
  45.             Case "December"
  46.  
  47.                 Dates = "12"
  48.  
  49.         End Select
  50.  
  51.  
  52.         con3.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\LICHIN\Desktop\mys\YS.mdb"
  53.  
  54.         con3.Open()
  55.         ds3.Clear()
  56.         sql3 = "SELECT * FROM sumPercent WHERE dates = " & cbMonth.Text & " AND Year(dates) = " & cbYear.Text & " AND plants = '" & yieldsummary.cbPlant.Text & "'"
  57.  
  58.         da3 = New OleDb.OleDbDataAdapter(sql3, con3)
  59.         da3.Fill(ds3, "sumPercent")
  60.         con3.Close()
Reply