Jim Lawrence (AccessD)
accessd at shaw.ca
Sat Feb 22 17:16:00 CST 2003
Hi Patricio: I am not sure I am reading completely clear but here are two ways to set the display value of the combo box: 1. Set the value of the bound column and the appropriate field will display. cmbMyComboBox = intBoundValue 2. You can completely control a combo boxes content and data location by taking control yourself. This is done by adding a function call to ComboBoxes' RowSourceType property and creating that function with a specific layout. See below for two examples simple cut and pasted from Access help. .... The following user-defined function returns a list of the next four Mondays following today's date. To call this function from a list box control, enter ListMondays as the RowSourceType property setting and leave the RowSource property setting blank. Function ListMondays(fld As Control,id As Variant,row As Variant,col As Variant,code As Variant) As Variant Dim intOffset As Integer Select Case code Case acLBInitialize ' Initialize. ListMondays = True Case acLBOpen ' Open. ListMondays = Timer ' Unique ID. Case acLBGetRowCount ' Get rows. ListMondays = 4 Case acLBGetColumnCount ' Get columns. ListMondays = 1 Case acLBGetColumnWidth ' Get column width. ListMondays = -1 ' Use default width. Case acLBGetValue ' Get the data. intOffset = Abs((9 - Weekday(Now))Mod 7) ListMondays = Format(Now() + intOffset + 7 * row,"mmmm d") End Select End Function The next example uses a static array to store the names of the databases in the current directory. To call this function, enter ListMDBs as the RowSourceType property setting and leave the RowSource property setting blank. Function ListMDBs(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant Static dbs(127) As String, Entries As Integer Dim ReturnVal As Variant ReturnVal = Null Select Case code Case acLBInitialize ' Initialize. Entries = 0 dbs(Entries ) = Dir("*.MDB") Do Until dbs(Entries) = "" Or Entries >= 127 Entries = Entries+1 dbs(Entries) = Dir Loop ReturnVal = Entries Case acLBOpen ' Open. ReturnVal = Timer ' Generate unique ID for control. Case acLBGetRowCount ' Get number of rows. ReturnVal = Entries Case acLBGetColumnCount ' Get number of columns. ReturnVal = 1 Case acLBGetColumnWidth ' Column width. ReturnVal = -1 ' -1 forces use of default width. Case acLBGetValue ' Get data. ReturnVal = dbs(row) Case acLBEnd ' End. Erase dbs End Select ListMDBs = ReturnVal End Function .... The above may be over-kill but I use a similar setup (class) for all my combo boxes and it is the root to the ultimate combo box control system. HTH Jim -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of Patricio Galleguillos Sent: Saturday, February 22, 2003 2:12 PM To: accessd at databaseadvisors.com Subject: RE: [AccessD] .NET Dear Group In a combo box that displays a list of values... How can I make the default value equal to the first element in the list so as not to have a blank when it first opens. The list of values is generated after the form opens. Thanks in advance Saludos Cordiales, Patricio Galleguillos pgallegu at chilesat.net _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com