Save Button (1 Viewer)

Zany

New member
Local time
Today, 06:19
Joined
Apr 23, 2021
Messages
7
Hi Guys,

I am new to using access. I have finally after 5 hours created a database and a form. All my combo Box and other necessary buttons are all good. But I want the user form to have a save button. Please anyone can provide me the basic step. The user form feeds the database system so its a bound Data I guess.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:19
Joined
May 21, 2018
Messages
8,525
In Access there is never a need for a save button, since it will always happen on its on. In fact it is pretty hard to stop it from saving. If anything you need an "un save" button to keep it from saving. Explain in more detail what you want and why.
This is done in the form's before update event. That is the point at which you can Cancel a record from updating.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:19
Joined
Mar 14, 2017
Messages
8,777
Some more discussions, approaches etc

 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:19
Joined
Feb 28, 2001
Messages
27,148
While MajP is absolutely correct, there IS an easy way to do this.

The SAVE button can be created in Form Design if you have the button wizards turned on. Create a command button. The button wizards will let you create any of several different functions. For Record Operations, one of the options is Save Record. Let the wizard build it for you.

You didn't say which version of Access you are using. On Ac2010, in Form Design view, you can find the Design tab (next to the Arrange and Format tabs). On the ribbon when the Design tab is selected, near the center you have the various controls you can place on the form. At the right-hand end of the box containing the controls, there is a place where you COULD have a vertical scroll bar if you needed one, and at the bottom of that scroll bar is a down-pointing arrow. Click that to see the option to turn wizard on or off.
 

Zany

New member
Local time
Today, 06:19
Joined
Apr 23, 2021
Messages
7
While MajP is absolutely correct, there IS an easy way to do this.

The SAVE button can be created in Form Design if you have the button wizards turned on. Create a command button. The button wizards will let you create any of several different functions. For Record Operations, one of the options is Save Record. Let the wizard build it for you.

You didn't say which version of Access you are using. On Ac2010, in Form Design view, you can find the Design tab (next to the Arrange and Format tabs). On the ribbon when the Design tab is selected, near the center you have the various controls you can place on the form. At the right-hand end of the box containing the controls, there is a place where you COULD have a vertical scroll bar if you needed one, and at the bottom of that scroll bar is a down-pointing arrow. Click that to see the option to turn wizard on or off.
Thank you. I think that's well explained to my understanding. I will work on it as instructed.

You have a great day.
Cheers!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:19
Joined
Feb 19, 2002
Messages
43,233
Access is all about saving data. Most people want to know how to stop Access from saving BAD data rather than wanting to know how to force Access to save changes at a specific point. Access ALWAYS saves your data (at appropriate points in time) UNLESS there is some Referential Integrity violation. The good and the bad of this is that bad data gets saved along with good data. It is your job to prevent the bad data from being saved. To do that, you need to understand how to use the FORM's BeforeUpdate event to STOP a record from being saved.

Once you realize that you have bad data being saved, check back and we'll help you with that:)
 

Umpire

Member
Local time
Yesterday, 22:19
Joined
Mar 24, 2020
Messages
120
To do that, you need to understand how to use the FORM's BeforeUpdate event to STOP a record from being saved.
Also New to Access. As I understand it, Access will save the data entered into a field as soon as you exit that field (move from one to the next on a form for example.)

If I am understanding your statement correctly, I can stop that automatic save (allowing a person to go back and edit field contents (fix a spelling error for example) until a point in time that I chose (hit a save button etc.)

Is this basically correct?
I can see where there is a place for that function. Adding it to my DB just became number 507 on my top 20 "To Do List"
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:19
Joined
May 21, 2018
Messages
8,525
No it is actually not saved to the table until you leave the record. Up until that point it is basically cached. The point of no return is the FORM's before update event. This event happens when you are leaving that record such as moving to a new record or closing a form. This is the place to do all validation and ensure you do/do not want to cancel the saving.

In this event you can check that everything required is filled in and data is valid. If not, you cancel the update and return to the form and not leave the record.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:19
Joined
May 21, 2018
Messages
8,525
Here is some code I have been using versions of validate. Easy and user friendly. This checks for required fields, but it is reusable in any form. Go to a new record and add some fields but not all required fields to see it work
 

Attachments

  • ValidateData V1.accdb
    564 KB · Views: 64

Umpire

Member
Local time
Yesterday, 22:19
Joined
Mar 24, 2020
Messages
120
No it is actually not saved to the table until you leave the record. Up until that point it is basically cached. The point of no return is the FORM's before update event. This event happens when you are leaving that record such as moving to a new record or closing a form. This is the place to do all validation and ensure you do/do not want to cancel the saving.

In this event you can check that everything required is filled in and data is valid. If not, you cancel the update and return to the form and not leave the record.
And this finally explains to me the heart of why using Access over Wi-Fi is such a bad idea. Wi-Fi drops for a microsecond, Access thinks you left the form and does its thing before you were ready for it to.

Thank you. I will add this to my argument with IT and Management over getting a hardwire connection added. (FYI I think it is mainly a Management ($$) issue rather than IT.)
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:19
Joined
May 21, 2018
Messages
8,525
There is a lot posted on this site on that subject.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:19
Joined
Feb 19, 2002
Messages
43,233
Access over WiFi can actually corrupt your BE which makes it especially dangerous. If you are using SQL Server as the BE, the WiFi drops are annoying but less likely to actually corrupt data.

If you have to work remotely, the best options are Remote Desktop and Citrix.
 
Last edited:

Isaac

Lifelong Learner
Local time
Yesterday, 22:19
Joined
Mar 14, 2017
Messages
8,777
And this finally explains to me the heart of why using Access over Wi-Fi is such a bad idea. Wi-Fi drops for a microsecond, Access thinks you left the form and does its thing before you were ready for it to.

Thank you. I will add this to my argument with IT and Management over getting a hardwire connection added. (FYI I think it is mainly a Management ($$) issue rather than IT.)
This is why I, respectfully to all herein, feel that Access as a desktop solution might be going into a decline more now than it has in the past (faster, etc). Many people are working from home. More than ever before, it seems to me. And many companies have found out that this works OK - after all, they had to make it work this time--and now, H.R. departments can no longer say "it doesn't work", because it just did. HR was faced with a dilemma: Either say it didn't work well, which is the equivalent of telling 1000's of employees, you did a bad job over the past year during COVID. Nobody was going to do that, so their only other choice is to say it worked fine and you did a great job, which is the equivalent of saying it can be done again.

Therefore, several very large companies that I know (and probably a lot that I don't) are now saying, "We might allow more remote work post-COVID than we did before", because demand for doing so is strong, and vague arguments against it have evaporated. One other thing I've noticed is that when a few large corporations start to do something, it becomes an unstoppable trend - like open seating in 'neighborhoods' rather than assigned cubes, now popular and seemingly unstoppable, no matter how ridiculous and chaotic it is :(

And, obviously, in the modern age, most people are using WI-FI. We can pontificate about how bad WI-FI is for Access, but you can't work for any major company and actually tell users nobody can use your database unless they all string ethernet cables all over their house, that just won't fly.

Remote desktop is awesome, if you have the two required machines - something at home, and something at work to log in to. Most corporations give a you a laptop and that's what you have at home, with nothing at work.

Citrix is a great option if your organization has a widely used Citrix environment that they are willing to dole out on the cheap to your department, I completely agree.

For the rest of us, it's hard to avoid the inevitable shift to alternate solutions. I'm trying to keep Access usage at my company as much as I can, but there's been a lot of challenges...
 

Umpire

Member
Local time
Yesterday, 22:19
Joined
Mar 24, 2020
Messages
120
There is a lot posted on this site on that subject.
You are correct. And I fully understand it is the absolute worst environment to try to run Access in.

But my Management does not know that. They say, " I use Word all day long over Wi-Fi with no problem." To them one Office program is just like all the other Office programs. And we all know that to be a falsehood.

Before, I was not able to give the REASON why it is bad for Access other than to say it leads to corrupt files. Now I can say it leads to corrupt files BECAUSE of how it saves records etc. My management are not very "Tech Savvy" people. To them I PC is an appliance like a coffee maker.

Fortunately their are only 3 users of my Database and 1 of those is already hardwired. And the other 2 are located on adjoining desks so a single run can be used to connect both of them. I think I have them about 75% convinced to spend the money to run the wiring. This information just might give me the last 25%.

As for using SQL for the back end, I am open to that but doing so is above my skill level right now. Once I get a fully developed database, I will explore what needs to be done to transition to using SQL. (I probably need to move it up my To Do list a bit.)
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:19
Joined
Mar 14, 2017
Messages
8,777
Fortunately their are only 3 users of my Database and 1 of those is already hardwired. And the other 2 are located on adjoining desks so a single run can be used to connect both of them. I think I have them about 75% convinced to spend the money to run the wiring. This information just might give me the last 25%.
That's a good situation! (y)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:19
Joined
Feb 19, 2002
Messages
43,233
The difference between Access and Word/Excel for example is that Word and Excel keep the "data" all in memory on the user's PC and perform temporary local saves and permanent saves back to the server as directed if that is where the document originated and Access keeps the application FE objects in memory on the user computer BUT the actual data is kept on the server in a shared database. With Word and Excel, the "data" is not typically shared. Only one user will be updating a Word document at one time. But with Access, the data is shared so many users will be updating the data at the same time. Access has to manage that update process. Data is saved at defined times and also when your code specifically requests a save. The danger point is if the WiFi blips during a save. The blip will always disconnect the FE from the BE but closing the FE and reopening gets you back working again. It is only dangerous if the blip happens during a save. If the blip happens while your form is dirty but before the record is saved, you'll loose what you typed in the form and have to reenter it after you reconnect. If some other user is interrupted while the two of you are working on a record in the same "block", you are BOTH affected.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:19
Joined
Feb 28, 2001
Messages
27,148
I'm going to toss in an explanation that @Umpire and @Zany can use for their IT departments in terms that they will understand. It is long but it has the details needed to correctly respond to IT arguments.

Access uses a protocol that is also used by Windows for File Sharing and Printer Sharing. It is called Server Message Block or SMB. Version 1 of SMB was the worst about this but SMB2 and SMB3 still have the similar problem. SMB is a member of the TCP family of protocols (as opposed to UDP, which is more web-oriented.) Being in the TCP family means it is NOT a connectionless protocol. SMB does use connections. With TCP connections, you get various security features including that message headers have sequence numbers so that you can re-assemble multiple packets in proper order. The connections are negotiated as would be the case for all TCP-family network sockets. You can also verify that nobody is inserting messages into your data stream because the sequence numbers are always, well..., sequential.

When you use SMB over WiFi, operation becomes critical when you have a WiFi "drop" event. At that moment, the connection breaks. The network driver will know very quickly due to loss of carrier. TCP technically allows a "reconnect" (a restoration of the network session) to occur if the network's security policies allow it. However, it is common for IT departments to disallow a reconnect. For instance, the U.S. Navy didn't allow reconnect events EVER. (Not limited to Access, not even limited to Windows systems.) This restriction is imposed to prevent an opportunistic hacker to reconnect to someone else's session, so it is an understandable restriction.

if session reconnection is disallowed then that connection is gone and the sequence numbering continuity is gone. The system has to start over again - but that means that any transfer that was in-progress is now forever interrupted. There is no getting it back, there is no chance of finishing any transmission that had been interrupted. Whatever was GOING to be sent cannot be sent now.

The corruption that we often discuss in association with WiFi is simply that with a network drop, you might actually do a PARTIAL update of a set of disk buffers. This partial update leaves the DB in an inconsistent state because PART of that buffer has been updated with new data but part has remained as old data. If the buffer in question contained structural meta-data (like an index table, for example) then that table's index is now totally corrupted and unusable. If a table was being compacted or if a massive update was underway at the time, that table is toast.

It is a fair question to ask "Why does Word or Excel work better over WiFi?" The answer is the pattern of their updates.

- Word doesn't write back anything until you do a SAVE or the automatic-update timer has expired, at which point the update (of the ENTIRE FILE) occurs in bulk. I think the Word default used to be 10 minutes, but to be honest, I never worried about that because I never used Word on a remote file anyway.

- Excel operates the same way. It does not do partial updates. Don't know if it has an auto-update timer, but doesn't matter. However, last I checked, Excel really DOES NOT LIKE file sharing with shared WRITE abilities. In our office, if you were updating an Excel file that was being shared, nobody else was allowed to do that while you were busy.

- Outlook USUALLY keeps a local .PST file so SMB isn't an issue unless someone has delegated shared authority to their post office or calendar. For the Outlook calendar, any updates are - in my experience - rare and not done piecemeal.

- PowerPoint ? Damned if I know its pattern intimately, but I know it saves on demand and perhaps it also saves when you switch to a new slide. Don't know if it has an automatic periodic save. But its save pattern is NOT nearly as frequent as the Access pattern.

- Access does updates whenever a user takes an action that would commit a change, and it DOES perform partial updates because that is how it preserves the ability to share back-end files. Therefore, Access has greater exposure to WiFi "drop" events because it is busier doing partial updates as needed to maintain data sharing in real time. That frequent partial SAVE pattern for Access is what gives power to its shared back-end database format, which allows smaller departments to do real database operations on a relatively smaller, inexpensive system.

There is a tendency for people to denigrate Access for its sensitivity to network drops. Hate to break it to them, but I've worked with a "big boy" database management system - ORACLE - and if there is a network drop between the ORACLE server and its network-attached storage device, you STILL have the same exact headache - a corrupted DB. If SQL Server is using network-attached storage, I guarantee it will have the same problems. Because Access is using a file-oriented protocol to "diddle around" in the back-end file, it should be compared to a system that has a database on a network-attached storage device. Therefore, make your comparison in an "apples-to-apples" manner. Don't compare Access on Wi-Fi to Word or Excel. Compare it to ORACLE or SQL Server with a flaky connection to network storage. Or compare it to a system which has Wi-Fi connections to network-attached storage.

That should be enough ammunition to make the case for hard-wiring an Access system.
 

Umpire

Member
Local time
Yesterday, 22:19
Joined
Mar 24, 2020
Messages
120
I'm going to toss in an explanation that @Umpire and @Zany can use for their IT departments in terms that they will understand. It is long but it has the details needed to correctly respond to IT arguments.

Access uses a protocol that is also used by Windows for File Sharing and Printer Sharing. It is called Server Message Block or SMB. Version 1 of SMB was the worst about this but SMB2 and SMB3 still have the similar problem. SMB is a member of the TCP family of protocols (as opposed to UDP, which is more web-oriented.) Being in the TCP family means it is NOT a connectionless protocol. SMB does use connections. With TCP connections, you get various security features including that message headers have sequence numbers so that you can re-assemble multiple packets in proper order. The connections are negotiated as would be the case for all TCP-family network sockets. You can also verify that nobody is inserting messages into your data stream because the sequence numbers are always, well..., sequential.

When you use SMB over WiFi, operation becomes critical when you have a WiFi "drop" event. At that moment, the connection breaks. The network driver will know very quickly due to loss of carrier. TCP technically allows a "reconnect" (a restoration of the network session) to occur if the network's security policies allow it. However, it is common for IT departments to disallow a reconnect. For instance, the U.S. Navy didn't allow reconnect events EVER. (Not limited to Access, not even limited to Windows systems.) This restriction is imposed to prevent an opportunistic hacker to reconnect to someone else's session, so it is an understandable restriction.

if session reconnection is disallowed then that connection is gone and the sequence numbering continuity is gone. The system has to start over again - but that means that any transfer that was in-progress is now forever interrupted. There is no getting it back, there is no chance of finishing any transmission that had been interrupted. Whatever was GOING to be sent cannot be sent now.

The corruption that we often discuss in association with WiFi is simply that with a network drop, you might actually do a PARTIAL update of a set of disk buffers. This partial update leaves the DB in an inconsistent state because PART of that buffer has been updated with new data but part has remained as old data. If the buffer in question contained structural meta-data (like an index table, for example) then that table's index is now totally corrupted and unusable. If a table was being compacted or if a massive update was underway at the time, that table is toast.

It is a fair question to ask "Why does Word or Excel work better over WiFi?" The answer is the pattern of their updates.

- Word doesn't write back anything until you do a SAVE or the automatic-update timer has expired, at which point the update (of the ENTIRE FILE) occurs in bulk. I think the Word default used to be 10 minutes, but to be honest, I never worried about that because I never used Word on a remote file anyway.

- Excel operates the same way. It does not do partial updates. Don't know if it has an auto-update timer, but doesn't matter. However, last I checked, Excel really DOES NOT LIKE file sharing with shared WRITE abilities. In our office, if you were updating an Excel file that was being shared, nobody else was allowed to do that while you were busy.

- Outlook USUALLY keeps a local .PST file so SMB isn't an issue unless someone has delegated shared authority to their post office or calendar. For the Outlook calendar, any updates are - in my experience - rare and not done piecemeal.

- PowerPoint ? Damned if I know its pattern intimately, but I know it saves on demand and perhaps it also saves when you switch to a new slide. Don't know if it has an automatic periodic save. But its save pattern is NOT nearly as frequent as the Access pattern.

- Access does updates whenever a user takes an action that would commit a change, and it DOES perform partial updates because that is how it preserves the ability to share back-end files. Therefore, Access has greater exposure to WiFi "drop" events because it is busier doing partial updates as needed to maintain data sharing in real time. That frequent partial SAVE pattern for Access is what gives power to its shared back-end database format, which allows smaller departments to do real database operations on a relatively smaller, inexpensive system.

There is a tendency for people to denigrate Access for its sensitivity to network drops. Hate to break it to them, but I've worked with a "big boy" database management system - ORACLE - and if there is a network drop between the ORACLE server and its network-attached storage device, you STILL have the same exact headache - a corrupted DB. If SQL Server is using network-attached storage, I guarantee it will have the same problems. Because Access is using a file-oriented protocol to "diddle around" in the back-end file, it should be compared to a system that has a database on a network-attached storage device. Therefore, make your comparison in an "apples-to-apples" manner. Don't compare Access on Wi-Fi to Word or Excel. Compare it to ORACLE or SQL Server with a flaky connection to network storage. Or compare it to a system which has Wi-Fi connections to network-attached storage.

That should be enough ammunition to make the case for hard-wiring an Access system.
The_DOC_Man,
Would you believe my management is asking if there are any formal studies or Technical documents stating that Access should not be used over Wi-Fi? They claim anything else is just "personal opinion."

So I guess for the foreseeable future, I am going to have to be content with de-normalized data and using only built in wizards etc. as I do not feel secure in developing anything more elaborate.

Thanks For all you have done to try to help me and others.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:19
Joined
Feb 19, 2002
Messages
43,233
Your original question was how to add a save button. You really need a save "prevention" procedure since Access makes it a personal mission to save every dirty record for you. Use the FORM's BeforeUpdate event to validate that the record to be saved is valid (has something for all required fields and has rational values for codes and dates and numeric fields. Cancel the update if you encounter any validation errors.

Now we end up with why Access doesn't work well on WiFi. Your management elects to not believe the experts. Not your problem. Do the necessary validation. Make sure you back up several times each day. Use SQL Server if you can. And, cross your fingers. Circulate your resume since they will blame you for any failures caused by WiFi blips.

Flattening the data will not make anything safer. It will simply open more opportunities to save bad data. That doesn't help anyone.
 

Users who are viewing this thread

Top Bottom