Making a Default Value Appear as "no"

rsingh4377

Registered User.
Local time
Today, 16:40
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!
 
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
 
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...
 
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!
 
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.
 
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
 
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

Back
Top Bottom