Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type mismatch in criterior expression

Status
Not open for further replies.

3239

Technical User
May 14, 2003
64
Could Someone Please help me with this code. I keep getting a Data Type mismatch in criterior expression. Run time Error 3464


Private Sub cboEmployee_AfterUpdate()
Dim D As Database
Dim rstEmp As Recordset
Dim strSQL As String


Set D = CurrentDb

strSQL = "Select * from tblEmployee Where"
strSQL = strSQL & "[SSN] ='" & Me.cboEmployee & "'"

Set rstEmp = D.OpenRecordset(strSQL, DB_OPEN_DYNASET)

Me!SSN = rstEmp("SSN")
Me!FirstName = rstEmp("FirstName")
Me!MiddleName = rstEmp("MiddleName")
Me!LastName = rstEmp("LastName")
Me!DateOfHire = rstEmp("DateOfHire")

rstEmp.Close


End Sub
 
If SSN is defined as numeric in tblEmployee:
strSQL = strSQL & "[SSN]=" & Me.cboEmployee

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Now I am getting a run time error 13 type mismatch
 
And which is highlighted ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Private Sub cboEmployee_AfterUpdate()
Dim D As Database
Dim rstEmp As Recordset
Dim strSQL As String


Set D = CurrentDb

strSQL = "Select * from tblEmployee Where"
strSQL = strSQL & "[SSN]=" & Me.cboEmployee

[COLOR=red yellow]Set rstEmp = D.OpenRecordset(strSQL, DB_OPEN_DYNASET)[/color]

Me!SSN = rstEmp("SSN")
Me!FirstName = rstEmp("FirstName")
Me!MiddleName = rstEmp("MiddleName")
Me!LastName = rstEmp("LastName")
Me!DateOfHire = rstEmp("DateOfHire")

rstEmp.Close
strSQL = strSQL & "[SSN]=" & Me.cboEmployee
 
Dim rstEmp As [highlight]DAO.[/highlight]Recordset

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try adding a space after Where OR before [SSN], as it is currently writen it states "Where[SSN]"

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top