Wrox Programmer Forums
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 5th, 2004, 12:15 AM
Authorized User
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data Type mismatch error

Can someone tell me what is wrong with this line:

SQL = "update tblGroupAndMembers set group_id = '" & !group_id & "' where member_id = '" & memberId & "'"

I keep getting 'Data type mismatch in criteria expression.' If i hard code memberId then I dont get the error. I dont understand what I am doing wrong. i defined memberID as Integer. The data Type for member_id in the tblGroupAndMembers table is number with field size integer. Can someone please help?

This line is in the following code:

With rstMemberId
     SQL = "insert into tblGroupAndMembers(member_id) values('" & !member_id & "')"
     db.Execute SQL
     memberId = !member_id
End With

      Set qdfTemp = db.CreateQueryDef("", _
        "SELECT group_id FROM tblGroupNames WHERE group_name = '" & cmbGroupName & "' ")
    Set rstGroupId = qdfTemp.OpenRecordset()
    With rstGroupId
    SQL = "update tblGroupAndMembers set group_id = '" & !group_id & "' where member_id = '" & memberId & "'"
     db.Execute SQL
End With


Old May 5th, 2004, 09:16 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

If Member ID is an integer, then

SQL = "update tblGroupAndMembers set group_id = '" & !group_id & "' where member_id = " & memberId

Don't surround it with single quotes.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data type mismatch sharon5469 ASP.NET 1.0 and 1.1 Basics 2 May 27th, 2007 10:01 AM
error 3464 'data type mismatch in criteria express Vince_421 Access VBA 3 May 3rd, 2007 06:45 AM
Data Type Mismatch Error in Criteria Expression mmcdonal Access VBA 2 March 1st, 2007 05:18 PM
data type mismatch karma SQL Language 3 April 6th, 2006 07:58 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.