[AccessD] Access 2007 - Type Mismatch

Gustav Brock Gustav at cactus.dk
Fri Jun 22 06:17:56 CDT 2007


Hi Gale

Try with:

strSQL = "SELECT * FROM MyTable WHERE MyField = '" & Me!MyField.Value & "'"

/gustav


>>> galeper at gmail.com 21-06-2007 22:38 >>>
Hi!

After converting a 2003 db to 2007, I'm getting a "Type Mismatch" error in a
field's BeforeUpdate code (the code checks to ensure the value hasn't
already been used).  The field is a text field, so the problem shouldn't be
that its value is in quotes.  Has anyone else experienced this or have any
ideas?  It worked fine before.

Thank you very much (code below),
Gale


Dim strSQL As String
strSQL = "SELECT * FROM MyTable WHERE MyField = " & Chr$(34) & Me!MyField &
Chr$(34)

Dim db As Database
Set db = CurrentDb

Dim rst As Recordset
Set rst = db.OpenRecordset(strSQL)

If Not (rst.EOF And rst.BOF) Then
    Cancel = True
    msgbox "This number has already been used.", etc.
End If
-- 






More information about the AccessD mailing list