473,554 Members | 3,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Default Value set the same as last valus for field

This should be a nice easy one for you lot.

I have got a Combo box, with its source as a value list - there are only two
options, AM and PM.

I want to set a default value in the box, depending on what the value for
the field was in the last record.

In other words I want to fill out a form, and select either AM or PM in the
list, then in the next record I want the AM/PM box to automatically take the
value that was last used.

Thanks
JB
Nov 13 '05 #1
2 6845
Use the AfterUpdate event procedure of the combo to set its DefaultValue

Private Sub cboAmPm_AfterUp date()
With Me.cboAmPm
If Not IsNul(.Value) Then
.DefaultValue = """" & .Value & """"
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Burns" <Jo*********@BA ESYSTEM.con> wrote in message
news:40******** @baen1673807.gr eenlnk.net...
This should be a nice easy one for you lot.

I have got a Combo box, with its source as a value list - there are only two options, AM and PM.

I want to set a default value in the box, depending on what the value for
the field was in the last record.

In other words I want to fill out a form, and select either AM or PM in the list, then in the next record I want the AM/PM box to automatically take the value that was last used.

Thanks
JB

Nov 13 '05 #2
Thanks,
I knew it would be a simple solution.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Use the AfterUpdate event procedure of the combo to set its DefaultValue

Private Sub cboAmPm_AfterUp date()
With Me.cboAmPm
If Not IsNul(.Value) Then
.DefaultValue = """" & .Value & """"
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Burns" <Jo*********@BA ESYSTEM.con> wrote in message
news:40******** @baen1673807.gr eenlnk.net...
This should be a nice easy one for you lot.

I have got a Combo box, with its source as a value list - there are only

two
options, AM and PM.

I want to set a default value in the box, depending on what the value for the field was in the last record.

In other words I want to fill out a form, and select either AM or PM in

the
list, then in the next record I want the AM/PM box to automatically take

the
value that was last used.

Thanks
JB


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3562
by: Sophie Bradshaw | last post by:
i was wondering if anyone could possibly help me! i have a ms access database, and in one of the tables, one of the fields is a lookup column, with several possible values. what i want to do is when i create a record and choose a value for the lookup, i want the next record to default to the value in the previous record in the lookup field....
11
12464
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this with a query but don't know what the criteria needs to be. Any help would be appreciated, Thanks
0
2417
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2 questions: 1) I would like the user update these text fields that get populated with data from the database. For some reason I get the error when I...
4
2429
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits System.Windows.Forms.Design.ControlDesigner I get an error saying that the Type is not defined. I cut and pasted all the imports and line from...
44
2725
by: gregory.petrosyan | last post by:
Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ????) print x All I want is to make self.data the default argument for self.f(). (I
74
15903
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the creation of this implicit default constructor, to force the creation of a struct via my constructor only? Zytan
4
2029
by: rczuba | last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match. I'm trying to create a payroll database for a small home business that I have that has had (and hopefully will continue to have) lots of growth. I have created a Transaction table to hold the hours, date, location of work (as the employees...
4
1511
by: ARC | last post by:
I have a form with a first name and last name field right next to each other. The last name field has no label. I'm using: defaultvalue="" and defaultvalue =="" for new recs so a beginner-type user knows what goes where. After looking at a customer's database, already the very first record, sure enough, has last name = "". I wish there...
5
4829
by: Henry J. | last post by:
I know this could be a dumb question, I just want to confirm that it is faster to execute inserts, if a timestamp field is set to have a default value, like DEFAULT CURRENT TIMESTAMP, and skip that column in inserts, than to include explicit timestamps in the inserts and let the DB insert them. Thanks!
0
7584
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7783
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7876
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6128
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3546
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
827
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.