Data type mismatch in criteria expression

M

Mike

I have two databases one a copy of the other on which i have changed one
field from a type it in integer to autonumber. On the original a peice of
code works fine now on the autonumber one i am getting the message "data type
mismatch in criteria expression" i would be extreemly grateful if someone
could explain what this means, possible causes or a solution. the section of
code causing the problem follow.
Many thanks in advance.

'Member' works fine on earlier lines

Dim RNDPassVal As String
RNDPassVal = Int(Rnd() * 10000000)
DoCmd.RunSQL ("UPDATE tblPassword SET Password = '" & RNDPassVal &
"' WHERE MemberID = '" & Member & "'")
DoCmd.RunSQL ("INSERT INTO tblLog
([MemberID],[PasswordChanged],[PasswordChangedTo]) SELECT '" & Member & "',
True ,'" & RNDPassVal & "'")
MsgBox ("Your Password has now been changed please phone to recieve
new password")
 
D

Dan Artuso

Hi,
If MemberID is your autonumber, you *can't* place a value into it. Access increments it automatically.
Remove it from your Insert statement.
 
D

Dan Artuso

Hi,
Sorry, didn't read the post properly.
Try changing you criteria expression to:
"' WHERE MemberID = " & Member)

Number shouldn't be delimited.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top