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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Value on Combo Box with two columns

Status
Not open for further replies.

handlebarry

Technical User
Dec 21, 2004
118
GB
hi - Having some problems seeting a default value and I think it's because there is more than one column (column widths set to 0cm,2cm)

Trying to get it to default to the first record in a table.
By amending previous threads I got to:

DMin("tblTeamLeaders.lngEmpID","tblTeamLeaders.strEmpName")

this is not working
any help appreciated

 
tried Me.cboEmployee.DefaultValue.Column(1) = "CWGLogin"

but this is giving me an invalild qualifier error
 
Hi, handlebarry,

I think you can only set the default value by using the bound column. Are you trying to set it in VBA? Or in the control's Default Value field in the property sheet?

I just tried it with both DMin and DMax in the control's property sheet and it worked:
Code:
=DMin("[MyField]", "MyTable")

Ken S.
 
p.s. And if you're trying to set it in code, remember the DefaultValue property is a string. If you try something like this, which *seems* like it should work, you may get strange results:
Code:
Me!Combo3.DefaultValue = DMax("[SSN]", "Members")
The above code resulted in a value of -9099 in my combo. Why? Well, the max SSN value in my table is 999-99-9999. Yup, 999 minus 99 minus 9999 equals negative 9099. However, this code works exactly as expected:
Code:
Me!Combo.DefaultValue = "=DMax('[SSN]', 'Members')"
This also worked:
Code:
Me!Combo3 = DMax("[SSN]", "Members")
However, you would want to be very careful where you placed this last example, as it would replace any existing value in the control.

HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top