Update multiple records with a command button

G

Guest

Hi

I have an issue with my database at the moment. I have a form based on a
query which shows records where Approval Status = Null. What I want to do is
have a combo button showing the different statuses. Once a status has been
selected they would then click on a command button to accept the changes.
This would then populate all blank status fields.

Can anyone help me with this?

Enigo
 
G

Guest

First Back up your data,

Try something like

' Check if status was selected
If IsNull(Me.[Status]) Then
MsgBox "Must select a status"
Exit Sub
End If
' Ask the user if he want's to continue
If MsgBox ("Would you like to update the record?", vbYesNo) = vbYes Then
CurrentDb.Execute("Update TableName Set StatusField = " & Me.[Status] & "
Where StatusField Is Null"), dbFailOnError
End If

Note: it air code, you need to change the names of the fields and then try it.
Also, if the status value is string, change the sql to

CurrentDb.Execute("Update TableName Set StatusField = '" & Me.[Status] &
"' Where StatusField Is Null"), dbFailOnError
 

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