Running an Update query on record and have Form show updated record

DLe

New member
Local time
Today, 08:00
Joined
Jan 15, 2015
Messages
6
hello! i want to see if someone can help me.

i want to be able to create an On Click Event when pushing a command button that will run an Update query to update a record and after it has been updated that specific record will pop up on a Form and be displayed. i know a different way is to run the Update query and then have it displayed in a Select query but i want it to be displayed on a Form instead. is it possible?
 
Well the general idea would be,
Code:
Private Sub buttonName_Click()
    Dim someValue As Long 
    
    someValue = 1234
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tableName SET fieldName = 'some value' WHERE idColumn = " & someValue
    DoCmd.SetWarnings True
    
    DoCmd.OpenForm "yourformName", WhereCondition:="idContolName = " & someValue
End Sub
 
I appreciate the reply Paul but kinda lost me with SQL. Below is what I have and I know it pretty much says kinda the same thing except bringing in a certain record on the Form. Let me say that my Update query updates a field called "Package Status" from a status of "Info Transmitted" to "Exception" and I need the Form to pop up with that record of an "Exception" status.

Private Sub cmd_UpdatePkg_Click()

Dim stUpdateExceptPkg As String
stUpdateExceptPkg = "qry_UpdateStatus"
DoCmd.OpenQuery stUpdateExceptPkg, acNormal, acEdit

On Error GoTo Err_cmd_UpdatePkg_Click

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close
stDocName = "frm_Delivery"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_UpdatePkg_Click:
Exit Sub

Err_cmd_UpdatePkg_Click:
MsgBox Err.Description
Resume Exit_cmd_UpdatePgk_Click

End Sub
 
Well you have declared a variable stLinkCriteria but never used it. Why?
 
I inherited this database so just used other code that it contained. I'm ok at reading the code but not writing it BUT I did figure it out and it works perfectly. Thank you for your assistance Paul!
 

Users who are viewing this thread

Back
Top Bottom