473,406 Members | 2,439 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,406 software developers and data experts.

How to store options ?

759 512MB
Hi all !
I have an unbound form with some controls (check boxes and option buttons) where I make some settings (i.e. AutomaticPrint - checked or unchecked check box, ReportToPrintName - option buttons and so on).
I need to store the user options for further use (in the next work session).
Of course I can store this options in a .txt file but Access is designed for databases, so I think that must be a way to store this options in a table.
Can you help me with some advices or/and some VBA code for that ?
Thank you !
Jun 20 '11 #1

✓ answered by Adam Tippelt

You could create a table where each column matches each option you have on the form.

Add some form of "Save settings" button to the bottom of the form, which triggers something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSave_Click()
  2. On Error GoTo cmdSave_Click_Err
  3. Dim db As DAO.Database
  4. Dim rst As DAO.Recordset
  5.  
  6. Set db = CurrentDb
  7. Set rst = db.OpenRecordset("YourSettingsTable")
  8.  
  9. rst.AddNew
  10. rst!AutomaticPrint = Nz(Me.AutomaticPrintControl,0)
  11. rst!ReportToPrintName = Nz(Me.ReportToPrintOptionFrame, 0) 'Stores the option 
  12. rst!Setting3 = Nz(Me.YourCheckBox, 0) 'Stores whether the checkbox was ticked or not. Ticked = -1, Unticked = 0.
  13. rst!Setting4 = Nz(Me.YourOptionFrame, 0) 'Stores the option value.
  14. rst.Update
  15.  
  16. End Sub
  17.  
That should allow you to store the settings in a table instead of a .txt file.

If you add a field in to store the current user as well, you could couple this code with a way of automatically reloading the current saved settings for the current user, and also a dlookup on the save button that checks the user field, if settings don't exist for the current user, rst.addnew, else rst.edit.
It really depends on how your system is designed and what functionality it includes.

Hope that helps.

Adam.

5 2501
Adam Tippelt
137 100+
You could create a table where each column matches each option you have on the form.

Add some form of "Save settings" button to the bottom of the form, which triggers something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSave_Click()
  2. On Error GoTo cmdSave_Click_Err
  3. Dim db As DAO.Database
  4. Dim rst As DAO.Recordset
  5.  
  6. Set db = CurrentDb
  7. Set rst = db.OpenRecordset("YourSettingsTable")
  8.  
  9. rst.AddNew
  10. rst!AutomaticPrint = Nz(Me.AutomaticPrintControl,0)
  11. rst!ReportToPrintName = Nz(Me.ReportToPrintOptionFrame, 0) 'Stores the option 
  12. rst!Setting3 = Nz(Me.YourCheckBox, 0) 'Stores whether the checkbox was ticked or not. Ticked = -1, Unticked = 0.
  13. rst!Setting4 = Nz(Me.YourOptionFrame, 0) 'Stores the option value.
  14. rst.Update
  15.  
  16. End Sub
  17.  
That should allow you to store the settings in a table instead of a .txt file.

If you add a field in to store the current user as well, you could couple this code with a way of automatically reloading the current saved settings for the current user, and also a dlookup on the save button that checks the user field, if settings don't exist for the current user, rst.addnew, else rst.edit.
It really depends on how your system is designed and what functionality it includes.

Hope that helps.

Adam.
Jun 20 '11 #2
NeoPa
32,556 Expert Mod 16PB
You're absolutely right to think that way Mihail. Many overlook that simple point.

It may sound very simple, but the answer is to bind the form to a table. This can be a control table if you like. You can filter it if you want a specific record from the table. Often, databases exist with a control table which contains a single record to manage overall database settings.
Jun 20 '11 #3
Mihail
759 512MB
Thank you both for answers.

Adam, I do not think as far as you teach me. With my database can work anyone, but is very useful to me your idea. I think I'll try to implement it in a next version.
Thank you again.

If someone else has new ideas please, let me know.
Jun 20 '11 #4
Rabbit
12,516 Expert Mod 8TB
I'm not sure what you mean Mihail. Adam's suggestion will work for "anyone" as you put it.
Jun 20 '11 #5
Mihail
759 512MB
Rabbit, is my english. Sorry for that. I mean that I do not implement users to my database. If I, you or anyone else open my database, can work in it (in database) without passwords or other troubles.
Even now I am not sure that I explain OK, because I learn english from the computer's help files so...
Adam's reply solve my question, but if anyone else has more suggestions he (she) is welcome.

Thank you for your interest.
Jun 20 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jared | last post by:
Store List Box values I have a form that has hundreds of records in it. The form has a list box with 10 different options in it. The user is able to select multiple options from the list box....
5
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
12
by: dbuchanan | last post by:
I am designing a table to contain a field to stores a value that must indicate none, one, or many choices. The form will have a group box with checkboxes (multi-choice) You see the records in...
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
3
by: Earl | last post by:
..Net Winforms app. I'm currently using the database to store user options. But I wonder if there is a better, faster technique. For a simple example, look at the Visual Studio 2005 Tools Options...
1
by: nrsutton | last post by:
Hi I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached...
21
by: Nick Craig-Wood | last post by:
Lance Gamet <lance@gamet.comwrote: I've found http://docs.python.org/lib/module-ConfigParser.html To be easy to use and built in. It makes human readable / editable ..ini - like files. ...
2
by: Sinister747 | last post by:
Hi All, I am creating an online store kind of thing, in the backend you can specify product options, such as color, disk space etc etc.. On the frontend it outputs the options into a select box...
0
by: Deepa Avudiappa | last post by:
We have designed a basic text editor using GTK+ in Ubuntu. We are supposed to store text files within a database(postgreSQL) which can be retrieved, viewed on our editor, modified using the options...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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.