473,472 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Changing a default value in a table

12 New Member
I am designing a database that will be used by many different offices, and each office may want to change the defaults I have in a table.

Rather than teach each user how to go in and change a table's default values, I want to create a user-friendly form that allows them to change the default values in the linked table.

Let's say I have a form field "office" on my form that is linked to the table field [department] in my table. The field [department] has a default of "shipping".

I want to let the user enter "receiving" into the form's "office" field and then click on a tiny button to "set as default" - which will then run some code to basicaly do something like:

department.default.value = me.office.value

But the property ".default.value" doesn't exist.

Is this possible, or do I have to maintain a separate table of default values and use code to update form data as needed?

Thanks!

PK
Jan 16 '08 #1
8 12548
FishVal
2,653 Recognized Expert Specialist
Hi, there.

Th property is the folowing:
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.TableDefs("TableName").Fields("FieldName").DefaultValue = ...
  2.  
Jan 16 '08 #2
missinglinq
3,532 Recognized Expert Specialist
Just to clarify, are you talking about each office having its own table, or does each office have its own frontend connecting to a single, common backend/table? If everyone is sharing a single table you need to be changing the default value at the form level, not the table level.

Welcome to TheScripts!

Linq ;0)>
Jan 16 '08 #3
peterkennett
12 New Member
Each office gets their own copy of the database. The data is not shared or linked, it is for their own use. I could go in and show each office how to customize the table defaults to their specific office, or write up some instructions on how to do this, but I want to share this database with hundreds of offices around the world so that's not the best, user-friendly way to do it.

PK
Jan 17 '08 #4
peterkennett
12 New Member
Fish, thanks for the code. It works, but alas, I have the same table open on the form that I want to make changes to, so I get an error!

Arghg!

I guess there is no way to update the defaults on a table that is open and being accessed. I think I need to store the defauts in a separate table.

PK
Jan 17 '08 #5
missinglinq
3,532 Recognized Expert Specialist
Why do you need to (or would you want to) have the table open when you're changing the default value? Just create a utility form for the sole purpose of changing the default!

Place a button (Call it ChangeDefault) and an unbound textbox (call it txtDefValue) on the form, then incorporating the code Fish provided:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ChangeDefault_Click()
  2. If Not IsNull(Me.txtDefValue) Then
  3.  CurrentDb.TableDefs("YourTableName").Fields("YourFieldName").DefaultValue = Me.txtDefValue
  4.   MsgBox "Default Value has been changed to " &    Me.txtDefValue
  5. Else
  6.   MsgBox "You must enter a new Default Value before you can assign it!"
  7.   txtDefValue.SetFocus
  8. End If
  9. End Sub
  10.  
This example is for changing a single Default Value, but you could, of course, easily modify to change multiple values.

Linq ;0)>
Jan 17 '08 #6
peterkennett
12 New Member
Thanks!

That is exactly what I did, but not with the nice error trap for non entries. Again, thanks for the help everyone! This is a VERY COOL forum!

PK
Jan 18 '08 #7
MRA2
6 New Member
Worked Great Thanks so much!!!!

@missinglinq
Dec 29 '17 #8
rccline
1 New Member
FANTASTIC! Thank missinglinq for that great post! I searched high and low for a solution to changing the defaul TableDefs using VBA...

Many Kudos to you!!

Best regards,
Robert
May 7 '18 #9

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

Similar topics

4
by: Johan Vervloet | last post by:
Does anybody know how I can change the default value for a column? I was trying to remove the default value in order to add the new one afterwards. This is what I tried: alter table...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
5
by: David Deacon | last post by:
Hi i was given the following advise,below my OriginalQuestion I am a little new to ADOX can you direct me to the following Do i place the code behind a button on a form? Or do i place it in the...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
0
by: spatik | last post by:
Hi, I have a tableevent] with a columnevent_description] as ntext and default value ''. Now, I want to change the column type to nvarchar(max) using this script, alter table alter column ...
6
by: JC21 | last post by:
Hi All, On my main table(tblCust) I have a field called Status, the default value is set to No. All the accounts currently in the table have a default value No. On my form I have a combo...
4
by: teddysnips | last post by:
A few weeks ago a client asked me to add a column to a table so I created this script: ALTER TABLE dbo.tblIndividual ADD fldRenewalStatus BIT NOT NULL CONSTRAINT fldRenewalStatus_Default DEFAULT...
7
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that...
1
by: Tim | last post by:
I'm working on a form where a combo box gets its list of values from a table. That same table also contains some "default notes" in other fields. My task is simple, but I'm having a hard time...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.