UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Field Default Value Same As Last Record?    
 
   
karenedmonds
post Mar 18 2012, 09:12 PM
Post #1

UtterAccess Veteran
Posts: 312
From: Melbourne, Australia



Hello!

Is it possible to have a field's default value = the last record?

I am creating a form to quickly add new records to the main table.
We are an emergency response group and often there are incidents where we need to add jobs quickly and in large numbers.
This is a simple form with just the base information to enable registering the job and giving it a job number.

On this form, I would like to have a field that nominates the incident type (ie. Xmas Day Flood).
What I would like to happen is the user types this into the field once, and then this field will default on each subsequent new record - until a different entry is made.
I don't want the user to have to keep choosing the item from a list box.

On the main form, this field will be a list box, which can be entered/changed at any time.

I hope this is explained well enough - pleae let me know if I can clarify further.

Thanks & regards.




Go to the top of the page
 
+
theDBguy
post Mar 18 2012, 10:46 PM
Post #2

Access Wiki and Forums Moderator
Posts: 47,918
From: SoCal, USA



Hi Karen,

What version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question.

How can we determine the "last" record? Do you have a date/time field that indicates when the record was created?

Just my 2 cents... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
pere_de_chipstic...
post Mar 19 2012, 03:10 AM
Post #3

UtterAccess VIP
Posts: 7,580
From: South coast, England



Hi Karen

If your form stays open between adding records, then the easiest way to do add the same value to a field is to change the control's defaultvalue property.

In the AfterUpdate event add the code

For a numeric value:
Me.ControlName.DefaultValue = Me.ControlName

For a text value:
Me.ControlName.DefaultValue = Chr(34) & Me.ControlName & Chr(34)

hth
Go to the top of the page
 
+
missinglinq
post Mar 19 2012, 08:41 AM
Post #4

UtterAccess Ruler
Posts: 2,655



Or, you can simplify things using

Me.ControlName.DefaultValue = """" & Me.ControlName & """"

which works for Fields with Text, Number, Date/Time and Yes/No Datatypes.

Linq ;0)>
Go to the top of the page
 
+
karenedmonds
post Mar 20 2012, 12:33 AM
Post #5

UtterAccess Veteran
Posts: 312
From: Melbourne, Australia



Awesome!!
That is working exactly how I want it to!
Thank you very much indeed! (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
 
+
missinglinq
post Mar 20 2012, 10:47 AM
Post #6

UtterAccess Ruler
Posts: 2,655



Glad we could help!

Linq ;0)>
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 04:28 PM