r/MSAccess • u/Legitimate-Bridge280 • 2d ago
[UNSOLVED] MS Accesss save button
Does anyone knows a way to create a save button in ms access which works like a ms visual winform.
becuase in ms visual you can use a gridline(its like a Datasheet subform but better) to edit/delete/add a record and it will still not save anything to the table, until i press on the save button.
before answering:
- i dont want a temporary table method because its so risky.
- i dont want to edit each records separately but all together. because it will take forever and it so districting at rush hours.
I'm new to MS Visual Studio but i have already used their save button feature and its so perfect.
4
Upvotes
•
u/AutoModerator 2d ago
IF YOU GET A SOLUTION, PLEASE REPLY TO THE COMMENT CONTAINING THE SOLUTION WITH 'SOLUTION VERIFIED'
Full set of rules can be found here, as well as in the user interface.
Below is a copy of the original post, in case the post gets deleted or removed.
User: Legitimate-Bridge280
MS Accesss save button
Does anyone knows a way to create a save button in ms access which works like a ms visual winform.
becuase in ms visual you can use a gridline(its like a Datasheet subform but better) to edit/delete/add a record and it will still not save anything to the table, until i press on the save button.
before answering:
I'm new to MS Visual Studio but i have already used their save button feature and its so perfect.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Amicron1 8 2d ago
nrgins is correct. Access behaves a little differently from Visual Studio in this regard. You basically have two options.
You can use an unbound form and manage all the changes yourself in VBA, using recordsets, arrays, or another method. This gives you complete control, but it's also a lot more work, especially when you're dealing with multiple records.
The other option is to use a bound form connected to a temporary staging table. This is probably the approach I would take. Let the user add, edit, and delete records in that table just like they normally would. When they click your Save button, use VBA to apply those changes to the actual tables. If they click Cancel, discard the staged changes.
I know you said you don't want to use temporary tables because they're risky, but I wouldn't necessarily agree with that. A properly designed staging table, preferably local to each user's front-end database, can be a perfectly reasonable solution. You just need to handle the inserts, updates, and deletes correctly when committing the changes.
You can also use a disconnected ADO recordset, as someone else mentioned, but that's a more advanced approach.
The bottom line is that Access doesn't natively provide the same multi-record Save behavior you're accustomed to in Visual Studio. You can certainly build it, but you'll need to manage that process yourself.
3
u/nrgins 487 2d ago
It's not the save button that you would need to change, but it's the form itself.
If you use a bound form, which is bound to a table and which has controls that are bound to the table's fields, then Access will manage it for you and will automatically save the record.
If you want a manual process then you'll have to use an unbound form with unbound controls and manage it manually with an array based on a user-defined type. It's a lot of work, but it would give you full control.
There might be a third party add-on that that does a lot of that for you. I'm personally not aware of any but there might be something like that.
1
u/WesternInevitable675 2d ago
Couldn't you use a just create a public boolean variable that tracks whether the save was user triggered or "form" triggered. Then use onClick, for the save button, to set the variable to true (user initiated). On the form beforeUpdate check if the variable is true (user initiated) or false (form triggered). If form triggered, cancel update or if user triggered, push record save
1
u/Silent_Reader_1 2d ago
You can’t run from temporary table in this case
1
u/projecttoday 1 1d ago
Doesn't MS Visual Studio offer you a choice of Visual Basic .Net or C#? Unless they've added Python or something since I last looked (which was some years ago).
Which are you using?
If you are capable of producing your screen with Visual Studio C# or whatever, why don't you just do it that way and forget about Access?
And if not, I'd go with the temporary-tables method. Risky? Why do you think temporary tables are risky?
1
u/ZookeepergameShot673 18h ago
I create save buttons just by using the refresh form function
1
u/ConfusionHelpful4667 58 2d ago
Unbound form.
1
u/NoviceAtWorks 2d ago
This is exactly why I stopped using Access and got a MS in Data Science. I actually had to learn SQL. When you learn the language , you can do all this in SQL. When you remain with Access, you limit yourself. A half dozen rdms will let you write transferable code. I wrote Access for eight years. I do not want to look at every piece of code three times to check if it's working. I write code and test it instantly. immediate feedback. You are on Windows system, using MS Access, with MS Visual Studio. Three Masters you must satisfy. Once you learn what ACID means, it will help with the knowledge.
0
u/k-semenenkov 2d ago
You probably need to take a look at ADO in memory recordset https://www.devhut.net/utilizing-in-memory-virtual-recordsets-in-microsoft-access/