• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

Don't want combo box to change (1 Viewer)

TB11

New member
Local time
Today, 09:55
Joined
Jul 7, 2020
Messages
10
I have a form with a combo box. I don't want the value of the combo box to change as I go to the next form tecord. Is there a way to stop the change?

Why: I have a form that I use for data entry for projects. The same project is involved for record after record. When I close the form, then when I tepen the form, I will select a new value, for a different project for the combo box. (The form is set to data entry only)

I don't want to change the default value for the combo box in the property sheet.

I appreciate any help.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:55
Joined
Oct 29, 2018
Messages
12,442
Hi. If you're saying you want to assign the value you selected to all new records, then you can definitely use the DefaultValue property using code. You don't have to change the design of the form.
 

TB11

New member
Local time
Today, 09:55
Joined
Jul 7, 2020
Messages
10
No I just want the same value until the form is closed.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:55
Joined
May 21, 2018
Messages
3,489
What I normally do in this case is set the default value to the last value selected. So the value stays the same until a different choice is made. But like TheDBguy said this is done in code changing the default value.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:55
Joined
Oct 29, 2018
Messages
12,442
No I just want the same value until the form is closed.
Hi. Right, but did you want the same value assigned to "new" records? If you don't want the value assigned at all, then you can just use an unbound control.
 

TB11

New member
Local time
Today, 09:55
Joined
Jul 7, 2020
Messages
10
Would you mind sharing the code, and where it goes? I'm a newbie, so....
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:55
Joined
Oct 29, 2018
Messages
12,442
Would you mind sharing the code, and where it goes? I'm a newbie, so....
Hi. You didn't answer any of my questions, but I'll go ahead and assume the answer is a "yes." If so, in the AfterUpdate event of your control, try the following code (please adjust to use the actual name of your object).
Code:
Me.ControlName.DefaultValue="""" & Me.ControlName & """"
Hope it helps...
 

TB11

New member
Local time
Today, 09:55
Joined
Jul 7, 2020
Messages
10
@theDBguy Sorry about not answering your questions. I want a temporary default value (the last value entered), with the temporary value staying until the form is closed, which could mean after 5-30 records are entered.

I will try your code tomorrow when I'm back on my computer. THANK YOU.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:55
Joined
Oct 29, 2018
Messages
12,442
@theDBguy Sorry about not answering your questions. I want a temporary default value (the last value entered), with the temporary value staying until the form is closed, which could mean after 5-30 records are entered.

I will try your code tomorrow when I'm back on my computer. THANK YOU.
Hi. You're welcome. Let us know how it goes.
 

Users who are viewing this thread

Top Bottom