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

TB11

Member
Local time
Today, 10:44
Joined
Jul 7, 2020
Messages
78
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, 08:44
Joined
Oct 29, 2018
Messages
21,360
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

Member
Local time
Today, 10:44
Joined
Jul 7, 2020
Messages
78
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, 11:44
Joined
May 21, 2018
Messages
8,463
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, 08:44
Joined
Oct 29, 2018
Messages
21,360
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

Member
Local time
Today, 10:44
Joined
Jul 7, 2020
Messages
78
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, 08:44
Joined
Oct 29, 2018
Messages
21,360
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

Member
Local time
Today, 10:44
Joined
Jul 7, 2020
Messages
78
@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, 08:44
Joined
Oct 29, 2018
Messages
21,360
@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