can't populate a combo box with value

  • Thread starter Thread starter Morris
  • Start date Start date
M

Morris

Maybe it's just impossible, but here is what I'm doing:

I've got a combobox called cmbCompany. It's Unbound and its rowsource
is 'qryRowsourceCompanies' that is:

SELECT Countries.CountryName, Companies.CompanyName,
Companies.AddressLine1, Companies.AddressLine2,
Companies.AddressLine3, Companies.ID
FROM Countries INNER JOIN Companies ON Countries.ID =
Companies.CountryID
WHERE (((Companies.Active)=True))
ORDER BY Countries.CountryName, Companies.CompanyName;

I've set the BoundColumn to 6 so that I can instantly get an ID of a
Company the user chooses. But I've also set the ColumnCount to 5 so
that the user doesn't see the IDs.

Now I've got this statement in the form's On Load property:
Me.cmbCompany = "Canada"

Now: The control appears to be empty, but Msgbox Len(Me.cmbCompany)
returns 6. So the value is there somehow it's not displayed.

The combobox has a LimitToList property set to YES if it's of any
difference.

Any help greatly appreciated
Morris
 
First, you can set your number of columns to 6, then change the column width
of the 6th column to 0" so it won't display.

Second, if you have installed Office 2003 sp3, then you need a hotfix to
allow your combo boxes to operate properly. I encountered that issue myself.
If you search for the hot fix you should be able to find it, as I don't know
the link of the top of my head. If you have trouble finding it, I'll have
access to my link in a bit and can post it then.
 
Morris said:
Maybe it's just impossible, but here is what I'm doing:

I've got a combobox called cmbCompany. It's Unbound and its rowsource
is 'qryRowsourceCompanies' that is:

SELECT Countries.CountryName, Companies.CompanyName,
Companies.AddressLine1, Companies.AddressLine2,
Companies.AddressLine3, Companies.ID
FROM Countries INNER JOIN Companies ON Countries.ID =
Companies.CountryID
WHERE (((Companies.Active)=True))
ORDER BY Countries.CountryName, Companies.CompanyName;

I've set the BoundColumn to 6 so that I can instantly get an ID of a
Company the user chooses. But I've also set the ColumnCount to 5 so
that the user doesn't see the IDs.

Now I've got this statement in the form's On Load property:
Me.cmbCompany = "Canada"

Now: The control appears to be empty, but Msgbox Len(Me.cmbCompany)
returns 6. So the value is there somehow it's not displayed.

The combobox has a LimitToList property set to YES if it's of any
difference.


The ColumnCount property MUST be the same as the number of
columns in the row source query, so chage it to 6.

The way that you hide a column from users it to set the
column's corresponding width to 0 in the ColumnWidths
property. If you do not specify a width, then Access
divides the control's Width up evenly among the columns
without a specified width. E.g. if you were not specifying
the ColumnWidths property before change it to
;;;;;;0
If you did specify the ColumnWidths before, change the 6th
column width to 0. E.g. if it's currently set to
.5;.3;1;.5;.7;.5
then change it to:
.5;.3;1;.5;.7;0
 
In addition to what you have already been told about the column count, you
need to understand that the bound column controls the datatype of the
control. Therefore, if the bound column is numeric then you need to place
the numeric value of "Canada" in the control to get it to show "Canada".
The combo and list controls have two bound entities. They have the bound
field which indicates which column of the RowSource will be actually saved
in the control and they have a RowSource which is generally a query. The
column widths property is used to control which columns are visible so it
doesn't matter which column is actually the bound column although, you will
have trouble in some instances if the bound column is not the first column
of the RowSource. The column that is actually visible on the form is the
first column whose column width is greater than zero.
 
Back
Top