Making a Default Value Appear as "no" (1 Viewer)

rsingh4377

Registered User.
Local time
Today, 01:07
Joined
Jun 17, 2019
Messages
39
Hi All,

I am attempting to make a default value of "no" appear on my form's combo boxes. There are about 20 different combo boxes in which an individual must select "yes" or "no" and from there press a button to find which criteria applies to their desired search. I am just having trouble making each combo box start off as "no". Please help if you know how! Thank you!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:07
Joined
May 7, 2009
Messages
19,233
add code to your Form's Load event:
Code:
Private Sub Form_Load()
Me.combo1 = "no"
Me.combo2 = "no"
Me.combo3 = "no"
...etc..
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:07
Joined
Oct 29, 2018
Messages
21,467
Hi. Or how about going to your form's design view, select all the combos together, and then go to the Data tab in the Properties Window and enter "No" in the Default Value property? Just a thought...
 

isladogs

MVP / VIP
Local time
Today, 07:07
Joined
Jan 14, 2017
Messages
18,216
Or you can set the default value to "No" in the property sheet for each combo.
You can select all the combos then do that for each of them at the same time.

EDIT I see the DBGuy beat me to it!
 

rsingh4377

Registered User.
Local time
Today, 01:07
Joined
Jun 17, 2019
Messages
39
Hi guys, thank you for all the suggestions. I have tried typing in "no" in the default value for each combo box already and that did not work. I also just tried the coding method but that had no effect on the outcome either. If you have any more suggestions I'd be happy to try them. I appreciate your help. Thank you so much.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:07
Joined
Feb 19, 2013
Messages
16,607
you are using a combobox - so what is the rowsource to your combo? if it is something like

0;No;-1;Yes

then set the default value to 0
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:07
Joined
May 7, 2009
Messages
19,233
if the bound column is numeric, assigning "no" will not do it.
try cj's suggestion. or if you don't know whether the no=0 or no=1, then create this function in your form:
Code:
Public function fncAssignNo(byref cbo as combobox) as integer
dim i as integer
dim iResult as integer
iResult=-1
for i = 0 to cbo.listcount - 1
if cbo.column(1,i)="No" then
    iResult= cbo.column(0, I)
    Exit For
End If
Next i
fncAssignNo= iResult
End Function
now, modify the Load event of the form:
Code:
Private sub form_load()
me.combo1 = fncAssignNo(me.combo1)
me.combo2 = fncAssignNo(me.combo2)
…
…
End Sub
 

Users who are viewing this thread

Top Bottom