473,569 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5516
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,
adLockOptimisti c
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=Tru e
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(Can cel As Integer)
If SaveClicked=Fal se 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.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 3 '08 #2
On Sep 3, 5:39*pm, "ErezM via AccessMonster.c om" <u45095@uwewrot e:
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,
adLockOptimisti c
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=Tru e
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(Can cel As Integer)
If SaveClicked=Fal se 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.c omhttp://www.accessmonst er.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
21929
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 play it without having to right-click and save. How can I force the browser to pop up the "save file as" dialog box instead of playing it? I know...
3
3870
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 will open the report and print the data for the current record - but it prints a blank record if the user hasn't left the record and returned, since...
4
4275
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 I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to...
22
5000
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 calling up another form or report that uses some of the same data. We came up with a work around that saves the current record's ID, does a
4
1602
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 ImageUrl="images/submit.gif" width="70" height="30"></asp:ImageButton>
2
6320
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 has maninpulated data in the text field and then tries to leave the page. The purpose is to prevent the user from accidentally losing his changes. ...
19
4013
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 first. The only way I can think of is by adding a flag to the record and setting it to true when user-1 opens the record. If user-2 tries to open it,...
3
3775
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 right now is that a row is already selected, and the items put into the text boxes, for all records that have been entered using the form. I don't want...
1
1818
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 subform2 inside of the subform1, (subform2 is three deep basically). If a user navigates away to a different page or attempts to close the form, I...
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.