473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Force user to save form data

Hi I'm trying to make a form that makes it optional for the user to
save the inputted data. If the user does not tap the save button
before leaving the form, the data is silently discarded.

This may seem like a strange request but it's a search form I'm
working on and I'd like the option to save common searches, so I've
set up a table to store saved searches.

Thanks for any help!
Ciarán
Sep 3 '08 #1
2 5503
hi
you can tacle this from 2 different sides:
either have
1. the form's controls (and the form itself) be unbound to anything, then
only when the SAVE button is clicked use code to save the details to a table
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset

rs.Open "SavedSearches", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
rs!Field1 = TextBox1
rs!Field2 = ComboBox2
rs!Field3 = CheckBox3
rs!Field4 = SomethingElse
rs.Update
rs.Close
Set rs = Nothing
End Sub

2. have the form and all it's controls be bound to the SavedSearches table,
then add a variable in the form's code window
Private SaveClicked as Boolean

then use
Private Sub cmdSave_Click()
SaveClicked=True
End Sub

and then, use the Form_Unload event to check the condition of SaveClicked. if
it's true, just let access save the record automatically, otherwise, undo the
changes

Private Sub Form_Unload(Cancel As Integer)
If SaveClicked=False Then Me.Undo
End Sub

i prefer solution 1, it's cleaner and safer

good luck

Cron wrote:
>Hi I'm trying to make a form that makes it optional for the user to
save the inputted data. If the user does not tap the save button
before leaving the form, the data is silently discarded.

This may seem like a strange request but it's a search form I'm
working on and I'd like the option to save common searches, so I've
set up a table to store saved searches.

Thanks for any help!
Ciarán
--
May all beings be happy.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 3 '08 #2
On Sep 3, 5:39*pm, "ErezM via AccessMonster.com" <u45095@uwewrote:
hi
you can tacle this from 2 different sides:
either have
1. the form's controls (and the form itself) be unbound to anything, then
only when the SAVE *button is clicked use code to save the details to atable
Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset

rs.Open "SavedSearches", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
rs!Field1 = TextBox1
rs!Field2 = ComboBox2
rs!Field3 = CheckBox3
rs!Field4 = SomethingElse
rs.Update
rs.Close
Set rs = Nothing
End Sub

2. have the form and all it's controls be bound to the SavedSearches table,
then add a variable in the form's code window
Private SaveClicked as Boolean

then use
Private Sub cmdSave_Click()
SaveClicked=True
End Sub

and then, use the Form_Unload event to check the condition of SaveClicked.. if
it's true, just let access save the record automatically, otherwise, undothe
changes

Private Sub Form_Unload(Cancel As Integer)
If SaveClicked=False Then Me.Undo
End Sub

i prefer solution 1, it's cleaner and safer

good luck

Cron wrote:
Hi I'm trying to make a form that makes it optional for the user to
save the inputted data. If the user does not tap the save button
before leaving the form, the data is silently discarded.
This may seem like a strange request but it's a search form I'm
working on and I'd like the option to save common searches, so I've
set up a table to store saved searches.
Thanks for any help!
Ciarán

--
May all beings be happy.

Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2008...
Excellent, sounds doable - thanks a lot - I'll try it out tomorrow and
let you know how it goes!
Ciarán
Sep 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
3
by: Jerry Hull | last post by:
I've got a very simple database, with a report that the user wants to be able to print for a single record immediately after entering the data. I've created a button on the data entry form that...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
4
by: Benny Ng | last post by:
Dear All, <input type="checkbox" name="chkAgreement" value="0">I agree with the above terms and conditions <asp:ImageButton ID="ImgBtnSubmit" Runat="server" CausesValidation=True...
2
by: noneya22 | last post by:
I'm using asp.net 2.0. I have a page that has a save button and a cancel button along with a text field. All controls are asp.net server controls. I have JavaScript that prompts the user if he...
19
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record...
3
by: e | last post by:
I have a form which includes a list box populated with items from a query. When a user double clicks on a row in the list box, each column item is put into a specific text box. The problem...
1
by: GR82BBlondie | last post by:
Have read several posts and it appears that forcing a user to use the "Save" cmd is not used. However, I have a situation with a main form that has three pages/tabs. Each page has a subform1 and a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.