|
-
Aug 16th, 2005, 09:28 PM
#1
Thread Starter
Member
Save button on a form
Hi,
I have a weird problem. In one of my forms which allows users to edit the record on my database, I have a save button. When the user has edited the form and clicks on the save button, the record is saved. I also have to maintain a log of who is accessing my database and doing what, so I have a separate function called log_save() which I call everytime the user clicks on the save button. But the problem is that if the user clicks multiple times on the save button, I get multiple entries on my Logtable. Is there a way to identify if a user has made any further changes after he has clicked the save button once? (Just like it is in microsoft word or whereever, when the user has clicked on the save button once and if he doesn't make any more changes then he can simply exit without being prompted to save changes again) I tried using form's Me.dirty event but apparently it doesnot serve the purpose.
Thanks
-
Aug 16th, 2005, 11:41 PM
#2
Re: Save button on a form
Sure thas an easy one. If you create a boolean variable at the form level you can set it to false after the forms loads. Then in each control change event you can set your boolean flag to True. When you click on the save button you change it back to false. If the variable is false when save is clicked you dont write out to your log file.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 17th, 2005, 12:42 AM
#3
Thread Starter
Member
Re: Save button on a form
thanks rob. Can I ask you another question?
Is there a way for me to manually set to false the form dirty property? Thanks
I made sure to rate your earlier post.
-
Aug 17th, 2005, 02:55 AM
#4
Re: Save button on a form
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 17th, 2005, 03:22 AM
#5
Thread Starter
Member
Re: Save button on a form
danny, this does not seem to work. Once I have done me.dirty = false, on subsequent edits or changes to the form the dirty property is not automatically set to true again
When you know you can do it, there is no power on earth that can stop you. 
-
Aug 17th, 2005, 03:46 AM
#6
Re: Save button on a form
The property will switch back to true as soon as a bound field control is changed..
For example when a form initially loads it's dirty property is False
As soon as a textbox has it's entry changed if you peform a msgbox stating simply
Then it should say True.. if it doesn't then your control is not bound.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 17th, 2005, 03:52 AM
#7
Thread Starter
Member
Re: Save button on a form
yes you are right. My control is unbound. Any way to get it done in this.
When you know you can do it, there is no power on earth that can stop you. 
-
Aug 17th, 2005, 04:12 AM
#8
Re: Save button on a form
What you will have to do is capture the control's original value before any changes are made.. then after it has been made check to ensure that it is different and then set the dirty property to true.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 17th, 2005, 04:16 AM
#9
Thread Starter
Member
Re: Save button on a form
does this mean, that I will have to do it for each and every control? Because in that case, using me.dirty is not the only soln. I might as well use any flag variable for the purpose.
When you know you can do it, there is no power on earth that can stop you. 
-
Aug 17th, 2005, 04:26 AM
#10
Re: Save button on a form
That is one of the things bound forms are good for..
Yes you will have to validate each control before sending it to the table..
If you do not want users directly changing the table's data then pull to a temporary table and bind the form to this.. therefore allowing an experienced user the option to review the changes and then submit them back to the main table..
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 17th, 2005, 04:42 AM
#11
Thread Starter
Member
Re: Save button on a form
When you know you can do it, there is no power on earth that can stop you. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|