Multi-Function Button (update field)

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

Guest

Hi,

I have a button that currently saves the record and sends an e-mail of the
record to a few default addresses and an address that comes from a field on
the form. The first function came automatically with the button, and I
figured out the code for the second function.

Now, I can't figure out how to code it to update a field in the form. I need
it to change the Status field to say 'Submitted'. Can anyone help me?
 
I have tried doing this:

Dim strSQL As String

strSQL = "UPDATE NSRData SET Status = 'Submitted'"
CurrentDb().Execute strSQL, dbFailOnErrorI

But it does not work.
 
Your statement will update all the records in the table with the status =
"Submitted"


you will need something like

strSQL = "Update NSRData Set Status = 'Submitted' Where yourpKey=" &
me.yourprimarykeyfieldontheform.value
 
I know this error means that I am doing something really stupid, but after I
change the statement to what you said I get this message when clicking the
button: "Too few parameters. Expected 1."
 
Private Sub SaveRecord_Click()
On Error GoTo Err_SaveRecord_Click


Me!Status = "Submitted"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String


stDocName = "Send E-Mail"
DoCmd.RunMacro stDocName

Exit_SaveRecord_Click:
Exit Sub

Err_SaveRecord_Click:
MsgBox Err.Description
Resume Exit_SaveRecord_Click

End Sub
 
Back
Top