Combo box default value

mslagle1

New member
Local time
Today, 05:28
Joined
Jan 19, 2007
Messages
4
Hi all

I would like to set the default value of a combo box to the value of a public variable and I do not know the correct syntax.

My variable is named techID.

Anyone have an idea?
 
Hello:

The syntax in code would be:

YourComboBoxName.DefaultValue=TechID

or Try

YourComboxName = TechID

Regards
Mark
 
Thanks for the response mhartman


For what I am trying to do it would work best to set the default value on the properties of the combo box. When I key a string in their such as "jones" I get the desired results. But I want to be about to populate this string from a variable. I am close but I keep getting #Name? instead of the string I have stored in my variable. Any other ideas?
 
Hello:

Store your string in the TAG property of the combo box.

Regards
Mark
 
Mark,

Maybe I am not understanding your meaning.

My variable is techID. I tried going into the properties of the combo box (last_name) and for the tag I entered =[techID].[value]. I even made a pop up to make sure that the variable was populated with a string (it was). I am not getting a default value in the last_name combo box when I go to a new record. If I just type the string into the default value property "Smith" I do get a default value when I add a new record.

I have also tried to do this progamatically on the button that populates my variable I entered:

Private Sub Command0_Click()
form1.last_name.DefaultValue = techID
End Sub

Any other suggestions? Am I doing what you are explaining?
 
Create a function in a module:
Code:
Public techID as String 'you should already have this part

Function GettechID()
GettechID = techID
End Function

Then, in the Default Value for your combo put:
Code:
=Nz(GettechID(),"No TechID!")
 
CraigDolphin, that is exactly what I was looking for!!

Thank You! :D
Thank You! :D
Thank You! :D
 

Users who are viewing this thread

Back
Top Bottom