Retaining drop down value for next record

dcavaiani

Registered User.
Local time
Today, 09:34
Joined
May 26, 2014
Messages
385
After choosing a dropdown value and filing in other required fields, I click Add Record. Is there a way to retain the same value in the dropdown list assuming it will often be the SAME AS dropdown value (e.g., the same customer) of the record I just added?
 
Perhaps you could set the Default Value property of the combo box in its After Update event. Something like:
MeComboBoxName.DefaultValue = Me.ComboBoxNAme
 
That did not to seem to do the trick.
 
I use this in one of my forms, but use a chkbox to select whether to retain the previous value.



Code:
Private Sub Ship_ID_AfterUpdate()
    If Me.chkCopy Then
        Me![Ship_ID].DefaultValue = """" & Me![Ship_ID].value & """"
    End If

End Sub

and

Code:
Private Sub Date_ID_AfterUpdate()
    If Me.chkCopy Then
        Me![Date_ID].DefaultValue = """" & Me![Date_ID].value & """"
    End If
End Sub
 
That did not to seem to do the trick.
I have checked that the code will work, so can you please post the actual code that you are using
 
Private Sub Customer_AfterUpdate()
Me.Customer.DefaultValue = Me.Customer
End Sub

I am also going to look into the checkbox idea - that may be an even better option ?
 
So if you go to a new record, select a customer and then move to another new record, then the combo should fill with the last value selected. Is this not what happens for you.
 
So if you go to a new record, select a customer and then move to another new record, then the combo should fill with the last value selected. Is this not what happens for you.

Nothing is highlighted/selected after the add button is pushed. Could it be the 2002 version I'm on ?
 
I use this in one of my forms, but use a chkbox to select whether to retain the previous value.



Code:
Private Sub Ship_ID_AfterUpdate()
    If Me.chkCopy Then
        Me![Ship_ID].DefaultValue = """" & Me![Ship_ID].value & """"
    End If

End Sub

and

Code:
Private Sub Date_ID_AfterUpdate()
    If Me.chkCopy Then
        Me![Date_ID].DefaultValue = """" & Me![Date_ID].value & """"
    End If
End Sub

Looked good,but having troubles? Does the chkCopy need to have an Event associated, I havethe event associated with the customer combo box:


Private Sub customer_AfterUpdate()
If Me.chkCopy Then
Me![Customer].DefaultValue = """" & Me![Customer].Value & """"
End If

End Sub
 
As soon as I clicl on a customer in the drop down on an ADD RECORD screen I get the error msg: Run-Time error 424 and object required and it debugs to this line

If Me.chkCopy Then
 
I may be off base here on my design but:

The form opens in an update mode - with the first record in the file chosen. I can move to a different record and make changes if I want OR click on an ADD RECORD button. The check box for the COPY is on the screen. Now when I am in add mode, I select a customer from the combo box and soon as I do that I get the error messages referenced. HOWEVER, IF I click the COPY Box b/4 I choose the customer and enter the rest of new record, it goes thru, then when the next add record screen come up - the customer IS selected. Some kind of a timing logic error on my part!
 
I don't think it will make a difference but try:
Msgbox Me.chkCopy
If Me.chkCopy = True Then
 
I did say that I had a checkbox that I selected when I wished to save the data for another record.

Just remove the reference to Me.chkCopy, you do not really need it unless you wish to use it as I do.?

Is the chkbox actually called chkCopy?

so just use

Code:
Me![Date_ID].DefaultValue = """" & Me![Date_ID].value & """"

and the same for any other field on the form.

Bob's solution is neater though. I got mine from googling a good few months back.

FWIW my form is a simple Access form. As I tab through the combo boxes and the rest of the fields, Access automatically adds a new blank record, which I then populate.

I had over 13000 records to enter, so was looking for the quickest way to do this, as previously I was using Ctrl & ' :D
 
Last edited:
See attached - need Coaching !
On what exactly. At first glance I can see many things that I would do differently.

In what way does the code that carries forward the customer name to a new record not work.
 
opens in update mode - uninvoiced records only

change an existing or click on add records to begin a new purchase invoice

at that add new record point - nothing is there yet that u want to copy

then enter 1st line of a new invoice click add entry - adds to table

blank screen appears again -

options - maybe all first 4 fields remain selected/highlighted and that's what i want

or

maybe not ?

so, if i want to repeat all of those 1st 4, i click copy and they re-select from record just added, else
i start a new add from scratch
 
u may be thinking relational 'header/detail' proper design, but that's not necessary here
 
u may be thinking relational 'header/detail' proper design, but that's not necessary here
Actually, IMHO proper design of tables is of paramount importance. Improper design is the root cause of many problems.
 

Users who are viewing this thread

Back
Top Bottom