Question Default Values through Applciation

Zippyfrog

Registered User.
Local time
Today, 04:45
Joined
Jun 24, 2003
Messages
103
Hey. I have been working with basic Microsoft Access for many years, creating basic forms, tables, queries, and reports. But I don't know how to do something that keeps coming up again and again - making a default value through coding.

What I have done for years is create a form that had a bunch of unbound text fields on it asking for the user to enter default values when the access database starts. Then, I would have a button that would hide the form, but it was still open, and whenever I needed a default value, I would refer to the unbound textbox object on the hidden open form.

I am sure there is a better way to do it, and would love to learn how to do it. Is this something I would use a module for? Basically I want to have a form that a user can set all sorts of defaults, and then whenever I need the default filled in for a new record, it would refer to the code instead of the hidden form that I currently do.

Is there a better way to do this? If so, could someone enlighten me on how to do this? Thanks in advance.
 
Hey. I have been working with basic Microsoft Access for many years, creating basic forms, tables, queries, and reports. But I don't know how to do something that keeps coming up again and again - making a default value through coding.

What I have done for years is create a form that had a bunch of unbound text fields on it asking for the user to enter default values when the access database starts. Then, I would have a button that would hide the form, but it was still open, and whenever I needed a default value, I would refer to the unbound textbox object on the hidden open form.

I am sure there is a better way to do it, and would love to learn how to do it. Is this something I would use a module for? Basically I want to have a form that a user can set all sorts of defaults, and then whenever I need the default filled in for a new record, it would refer to the code instead of the hidden form that I currently do.

Is there a better way to do this? If so, could someone enlighten me on how to do this? Thanks in advance.

You can have that hidden form actually write those values to a record on a table and then refer to the table for your default values. I've done this in quite a few forms. Whenever they submit new default values, you can have it wipe out the table and make a new record.
 
How would you go about doing that? Deleting the records I mean. I have tried tying it to a table called tblDefault in the past, but I have found that it creates a new record each time, thus there are multiple records in the default table, and that doesn't work well.
 
This link might interest you:

http://www.experts-exchange.com/Microsoft/Applications/dBase/Q_25122603.html

Or like Vassago mentioned have a table with fields defined like this (for example):

Code:
FormName          ControlName         ControlDefaultValue
You can retrieve the value with a simple DLookup or write to the table with an INSERT/UPDATE statement.

Before you add a new default value, might be worthwhile to check if that ControlName exists, and if it doesn't INSERT. However, if it does, you UPDATE.
 
Last edited:
You can use vba to

DoCmd.RunSQL "delete * from tbl_master"

Or link it to a delete query that wipes out the table (thus wiping out the one record.
 

Users who are viewing this thread

Back
Top Bottom