[AccessD] Access 2007 - Type Mismatch

Gale Perez galeper at gmail.com
Fri Jun 22 17:59:26 CDT 2007


Thank you, Jim!  That was what I had originally, and it worked just fine in
Access 1997 and 2003, but I got the old "Type Mismatch" error in 2007.  I
remember now that even when I commented out the rst bit and just ran the bit
to capture strSQL, I still got the error.

I just changed it all to use dlookup instead for this purpose, but I'm
getting a lot of "Type Mismatch" errors in other parts of my forms where I
wasn't before.  Back to the drawing board!

Thank you all again for your help, and have a great weekend.
Gale


On 6/21/07, Gale Perez <galeper at gmail.com> wrote:
>
> 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