Text ForeColor of ComboBox fields

Alan Chan

Registered User.
Local time
Today, 16:54
Joined
Aug 28, 2013
Messages
14
I am working on a database project using Access 2010 and encounter some ComboBox text color problem and would like to seek assistance.

The form has a ComboBox that displays the Supplier Name. The Combo's source control is Supplier ID in the Products table which joints the Supplier Table containing the Supplier Name. To display the Supplier Name only, I use a column count of 2 (for VendorID and VendorName) and column width of 0";2" so as to hide the SupplierID.

VBA is used to dynamically change the ForeColor and BackColor (via the Control Property ".ForeColor" etc) of the text in the ComboBox and TextBox. This works well for all TextBoxes and the ComboBoxes with direct data from the Products Table. However, for the ComboBox of VendorName, the BackColor can change but the ForeColor always remains as black. I have tried using the Format query such as "[White];@;[White];@" which works on the TextBox and other ComboBox (with direct field data from table), but the situation remains the same on this ComboBox which uses join-table reference via the VendorID.

Grateful if any expert could help.

Thanks

Alan Chan
 
Post the VBA as well as the SQL for the row source for the combo box.
 
I have also posted this on the VBA and Modules Forum.

Thanks.
 
[Solved]: Text ForeColor of ComboBox fields

The code to change text color is like:

Private Sub CommandButton_click()
ComboVendorName.ForeColor = vbWhite
ComboVendorName.BackColor = vbMagenta

ComboProductName.ForeColor = vbWhite
ComboProductName.BackColor = vbMagenta
End Sub

On button click:
VendorName text turns to Black on Magenta background
ProductNameName text turns to White on Magenta background

I later discover that it works on simple Products and Supplier tables and find out that the problem was caused by the Supplier Table which I had performed export to Excel to manipulate record data changes and then import to make a new Supplier Table. Don't know why this only affects the text forecolor.

After making a new Supplier Table by editing an old working one without exporting to Excel, everything works.
 

Users who are viewing this thread

Back
Top Bottom