Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Value for ComboBox

Status
Not open for further replies.

carlingac

Technical User
Jan 31, 2005
25
GB
Hi

I dont know if this can be done with comboboxes. I have a ComboBox on a form set to use formula for choices with the choice being "@DbColumn("":"RECACHE";"":"";"staff";1)"

When the form loads the DBcolumn pulls back the fields, but i would like to have a default value set at the top of the list.

for example the combobox would just say something like "please select" and when you select it will then show all the values from the DBcolumn lookup.

If any one knows how/if this can be done it would be much appreciated

Many thanks

 
Put the list in a temporary variable, and insert your default value first in the list.

Pascal.
 
Sorry Pascal i dont really understand, i had a look in the help guide and understand the syntax is variableName := value, but i havent a clue where to start. Could you Elaborate further for me.

When you say list do you mean the lookup formual "@DbColumn("":"RECACHE";"":"";"staff";1)?,

Sorry for my naivety

many thanks
 
I don't mean to be naive, but could you not just type "Please Select" in the DefaultValue section of the field, and then still use the lookup?

What pascal means is to do something like this:

tmplist := "Please Select" : @DbColumn("":"RECACHE";"":"";"staff";1)

(I've not tried this, it might need tweaking!)
 
Thanks Fishkake, but I already tried the same way as you suggested but it did not work.

any other ideas?

Many thanks
 
HI,

I got it to work by doing the following:

Completed_By:="";"Please Select":mad:DbColumn("":"RECACHE";"":"";"staff";1)

(Completed_By was my ComboBox field)

But i just got lucky trying different things. I dont understand why i couldnt just have:

Completed_By:= "Please Select":mad:DbColumn("":"RECACHE";"":"";"staff";1)

Instead of having to put Completed_By:="";"Please Select":mad:DbColumn("":"RECACHE";"":"";"staff";1)

Any one know why?

Oh well, at least it works. thanks guys!


 
I'm confused... Is this formula in the "Use formula for choices" section of the field?

What you're doing there is setting the variable Completed_By to "", and then specifying a list of options made up of "Please Select" and the DbColumn. A semicolon simply ends the declaration of the variable, the same as putting:

Completed_By:="";

"Please Select":mad:DbColumn("":"RECACHE";"":"";"staff";1)

If I'm right, and if this is the case, then the first part doesn't actually do anything! All you need is the second line, inside the "Use Formula for choices" section.
 
Yes i am using the "Use formula for choices" section.
I have just done what you said, i used:

"Please Select":mad:DbColumn("":"RECACHE";"":"";"staff";1)

And this works fine, just the same.

So there was no need for a Temp Variable after all!

What is the colon : that separates "Please Select" & @DbColumn("":"RECACHE";"":"";"staff";1) actually saying?

many thanks for you help.

 
A colon seperates two values in a list. If you choose "List choices (one per line)" and type in the following:

Fish
Eggs
Cheese
Milk

Its the same as choosing "Use formula for choices" and typing this:

"Fish":"Eggs":"Cheese":"Milk"

The @DbColumn returns a list taken from the view column, and you are saying "make a list of 'please select' and the list returned by this function". Does this make sense?

As Pascal will tell you, I've wrestles with lists in the past, starting to get the hang of them now!!
 
Yeah that makes perfect sense thanks. I was initially trying to make please selet a default value but by using the list method it dose a better job for me anyway.

Many thanks for your help and time in explaining it to me.

You learn something new every day!

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top