473,386 Members | 1,715 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,386 software developers and data experts.

Default values in a form need to populate another field

93
I thought I posted this earlier but must have not completed it.

I have a field Status that I have a default value on of Open when a user adds a new record. This is an older form and I just added the default to avoid people leaving it blank. This same field also populates another field based on the selection they make in the field Status.

My problem now is if the user keeps the default (does not change it to another selection or does not manually change it to open) it does not populate the other field.

Anyone have any suggestions.
Sep 19 '08 #1
9 3376
missinglinq
3,532 Expert 2GB
You need to call the event that does the calculation from the Form_Current event if the record is a new record.

For instance, say you have a field called Field1, with its Default Value set to 100. In its AfterUpdate event you use a calculation

Me.Field2 = Me.Field1 * 5

to assign a value to Field2.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Field1_AfterUpdate()
  2.   Me.Field2 = Me.Field1 * 5
  3. End Sub
To make sure this calculation is done if the Default Value is retained, you'd need this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord Then
  3.   Field1_AfterUpdate
  4. End If
  5. End Sub
When a new record is created, Field2 will be assigned the value of 500. If the value of Field1 is changed, the value of Field2 will also be changed.

Linq ;0)>
Sep 19 '08 #2
missinglinq
3,532 Expert 2GB
Your duplicate posting of this question/problem has been deleted! Please refrain from this prohibited behavior in the future.

From FAQs

Do Not Double Post Your Questions

Double posting is where you start a thread on a topic and then for some reason start another thread on exactly the same topic in the same forum. Please do not do this because

1. It makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.
2. It swamps the forum with your problem resulting in less attention for the other threads.

If you feel for some reason that you post has been overlooked (for instance it hasn't had any replies) please do not repost the question. Post a message to the thread you started, this will bump it back to the top of the thread list for the forum.


Thank you for your attention in this matter.


Linq ;0)>

Moderator
Sep 19 '08 #3
clloyd
93
Please read my first line:

I thought I posted this earlier but must have not completed it.

It was an accident. I would never double post on purpose.
Sep 19 '08 #4
clloyd
93
I already have code that does all this the problem is if you accept the default and don't change anything the code does not work. If I manually change the default it works fine and populates the other field. Am I understanding your response or am I missing a step.
Sep 19 '08 #5
missinglinq
3,532 Expert 2GB
You're missing a step! How are you assigning a value to the second field? Normally this would be done in the AfterUpdate event of the first field, and the fact that this doesn't work when the Default Value is retained tends to support this supposition. We need to see your code including the sub header.

Linq ;0)>
Sep 19 '08 #6
clloyd
93
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Substatus_AfterUpdate()
  3.     Me.Status = Stat(Me.SubStatus.Value)
  4.  
  5. End Sub
  6.  
  7.  
This is my after update code.
Sep 22 '08 #7
clloyd
93
I still have not resolved this. Does anyone have any ideas?
Oct 3 '08 #8
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Form_Current()
  2.     If Me.NewRecord Then
  3.       SubStatus_AfterUpdate
  4.     End If
  5.     End Sub
  6.  
Linq ;0)>
Oct 3 '08 #9
clloyd
93
It did not populate the other field. Thanks though.
Oct 6 '08 #10

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

Similar topics

2
by: Todd D. Levy | last post by:
I have a table of Country names & Country codes in alphabetical order. This is a lookup table that a number of other tables use to populate the Country field via a drop down Combo Box on the...
2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
3
by: User | last post by:
Form A (Main) Text Box 1 Text Box 2 Text Box 3 Form B (Pop-up) Choose a selection for Form A/Text Box 3 Scenario:
7
by: Aaron Smith | last post by:
How do I set field default values at runtime? Say I want a check box that is bound to a boolean field to default to false for a certain set of criteria, and then true for others? I also need to do...
9
by: Good Man | last post by:
Hi This is sort of a weird question, perhaps a bit off-topic... I am on the 'edit' screen of a web form, and I have a bunch of variables coming from a database that need to be placed into the...
1
by: tnriverfish | last post by:
I've got a text box on a form where the default value shows - C:/ The user can change the default to whatever they want - D:/ I'd like to put a button next to the field that will change the default...
4
by: greg | last post by:
Hi, I don't think my message posted correctly so here it is. Is there any way to access the individual values of a form text box? I want to iterate through all of the rows and access the...
0
by: SimpDogg | last post by:
Hey guys another Newbie here... I have a combobox(JobName) on my form tied to a table named (Jobs) with one field for all of the jobs in the comboxbox. I want to auto populate the Due Out Date...
4
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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...

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.