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 !
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: - Private Sub cmdSave_Click()
-
On Error GoTo cmdSave_Click_Err
-
Dim db As DAO.Database
-
Dim rst As DAO.Recordset
-
-
Set db = CurrentDb
-
Set rst = db.OpenRecordset("YourSettingsTable")
-
-
rst.AddNew
-
rst!AutomaticPrint = Nz(Me.AutomaticPrintControl,0)
-
rst!ReportToPrintName = Nz(Me.ReportToPrintOptionFrame, 0) 'Stores the option
-
rst!Setting3 = Nz(Me.YourCheckBox, 0) 'Stores whether the checkbox was ticked or not. Ticked = -1, Unticked = 0.
-
rst!Setting4 = Nz(Me.YourOptionFrame, 0) 'Stores the option value.
-
rst.Update
-
-
End Sub
-
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
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: - Private Sub cmdSave_Click()
-
On Error GoTo cmdSave_Click_Err
-
Dim db As DAO.Database
-
Dim rst As DAO.Recordset
-
-
Set db = CurrentDb
-
Set rst = db.OpenRecordset("YourSettingsTable")
-
-
rst.AddNew
-
rst!AutomaticPrint = Nz(Me.AutomaticPrintControl,0)
-
rst!ReportToPrintName = Nz(Me.ReportToPrintOptionFrame, 0) 'Stores the option
-
rst!Setting3 = Nz(Me.YourCheckBox, 0) 'Stores whether the checkbox was ticked or not. Ticked = -1, Unticked = 0.
-
rst!Setting4 = Nz(Me.YourOptionFrame, 0) 'Stores the option value.
-
rst.Update
-
-
End Sub
-
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.
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.
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.
I'm not sure what you mean Mihail. Adam's suggestion will work for "anyone" as you put it.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |