Update Query (1 Viewer)

gakiss2

Registered User.
Local time
Today, 07:38
Joined
Nov 21, 2018
Messages
168
Trying to update a record in a table based on a click. I done something similar in another db so I copied the code then changed in the right fields expecting all to work like clockwork.

does is EVER go like that?

I am getting a type mismatch error but I can't understand what I am doing wrong. Pls help

Private Sub CmdRescind_Click()
Dim updMRR As String
' Code to rescind an MRR from the suppliers record
If MsgBox("Are you sure you want to rescind this MRR?", vbYesNo + vbQuestion) = vbYes Then
If IsNull(Me.Notes) Then
MsgBox "You must enter the reason in the Notes"
Exit Sub
End If
Else
MsgBox "No Action Taken"
Exit Sub
End If

updMRR = Me.mrr_num


MsgBox "Now we Rescind the MRR" & updMRR

** - troubleshooting code - updMRR does contain the string that I am looking for. I don't really need to use a variable but the db I pulled the code from used one so I used one here

CurrentDb.Execute "Update [NewRawImportMRRKey] Set [qty_rejected]= 0 where [mrr_num]= '" & updMRR & "'"

End Sub

I did try it out without the where clause and it behaved as expected, set qty_rejected to 0 for all records. Obviously this is not what is wanted but it did show the that statement up to the where clause is correct.

Thanks in advance.
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:38
Joined
Sep 21, 2011
Messages
14,235
if mrr_num is numeric, you do not use the single quote character '. That is for text?
 

gakiss2

Registered User.
Local time
Today, 07:38
Joined
Nov 21, 2018
Messages
168
Yes, that did it. Thank You
 

Users who are viewing this thread

Top Bottom