Access ComboBox Columns ForeColor

Alan Chan

Registered User.
Local time
Tomorrow, 07:41
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
 
can you post your code on how you're dynamically changing the ForeColor and BackColor for:
1) the objects that work ok
2) the objects that don't work

David
 
Hi David,

Thanks for the advice.

Actually 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

In the progress of making a simple ComboBox screen (original screen has over 30 Combos and TextBoxes) for demo to you, I discover that it works on simple Products and Supplier tables. I later 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.

Thanks

Alan Chan
 

Users who are viewing this thread

Back
Top Bottom