How to set two operations assigned to one button?

Lasidu Chamikara

New member
Local time
Tomorrow, 01:54
Joined
Apr 9, 2020
Messages
6
Hii, in my database, after entering required data in designed fields in a form, I want to display a message box as well as add those records to the relevant table at the same time. How can I perform this using a single button not with two separate buttons?
 
Just add both items to the button click event procedure.
You may need a DoEvents line after the first item to ensure processing is completed before the second item.
Suggest the message box is the second item as code stops until the OK button is clicked
 
Thank you very much for replying.
I'm not very much good on Access, just a beginner. Here what I actually want to happen; there is an "Add Record" button in my form and when the user clicks it, I want to add the record as well as display a message box consisting what he has entered. Can you please further explain how to add those two functions to button click event procedure..?
 
It sounds like you are using an unbound form which makes for a lot of unnecessary work.
If you have a bound form, data is saved automatically (though validation checks can be applied first)

Anyway if you have an unbound form, you can use code like
Code:
CurrentdB.execute "INSERT INTO YourTableName VALUES FieldName1='" & me.txtField1 & "', .... "

After that add your message box code e.g.
Code:
MsgBox "You have just added a record to table YourTableName"
 

Users who are viewing this thread

Back
Top Bottom