Data type mismatch in criteria expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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")
 
Hi,
If MemberID is your autonumber, you *can't* place a value into it. Access increments it automatically.
Remove it from your Insert statement.
 
Hi,
Sorry, didn't read the post properly.
Try changing you criteria expression to:
"' WHERE MemberID = " & Member)

Number shouldn't be delimited.
 
Back
Top