Problem with color in subform

  • Thread starter jubiiab via AccessMonster.com
  • Start date
J

jubiiab via AccessMonster.com

I have form with a subform. On the mainform I have a history of all kind of
machine parts. In the subform I have information of a supplier. Some Machine
ID’s have more then one supplier attached.

The subform look like this if I have more then one supplier attached to a
machine (only showing few fields and I using continues form view):

[SupplierID] [SupName] [SupMachineID] [SupMachineName] [UseSupplier]
1 Test1 54564763 MachineTest
[_] (checkbox)
2 Test2 9788979 MachineTest2
[x] (checkbox)
3 Test3 9788979 MachineTest3
[_] (checkbox)

I am using this code in the subform:

Private Sub Form_Current()

If Me.UseSupplier = True Then
Me.SupName.ForeColor = vbGreen
Me.Supname.FontBold = True
Else
Me.Supname.ForeColor = vbBlack

End If
End Sub

My problem is when I have a checkmark in the checkbox I get all [SupName]
green. I just want to have (like in the example above) [SubName]=Test2 to
become green. What am I doing wrong?

Sorry about my English.
 
J

jubiiab via AccessMonster.com

The subform should look like this:

[SupplierID] [SupName] [SupMachineID] [SupMachineName] [UseSupplier]
1 Test1 54564763 MachineTest
[_] (checkbox)
2 Test2 9788979 MachineTest2
[x] (checkbox)
3 Test3 9788979 MachineTest3
[_] (checkbox)
 
L

Linq Adams via AccessMonster.com

If the subform is in Datasheet or Continuous View, as most are, you cannot do
this kind of formatting thru code in the Form_Current event. You'll have to
use the Conditional Formatting from the Format Menu.
 
J

jubiiab via AccessMonster.com

what do i write in Conditonal formatting?? Can you give me an example of code?
 
L

Linq Adams via AccessMonster.com

Sorry, meant to give you a step-by-step:

Goto Format - Conditional Formatting

Under Condition select "Expression Is"

Then in the next box enter

[UseSupplier] = -1

Now simply use the icons to set the Forecolor you want and Bold it.

Now click on OK

You should be set.

BTW, the only kind of formatting you can do on these types of forms, using
code in the Form_Current event, is to Lock/Unlock and Enable/Disable controls.
 
J

jubiiab via AccessMonster.com

Hi Linq,

when i write this:
[UseSupplier] = -1

I get this message:
The expression you entered contains invalid syntax

Linq said:
Sorry, meant to give you a step-by-step:

Goto Format - Conditional Formatting

Under Condition select "Expression Is"

Then in the next box enter

[UseSupplier] = -1

Now simply use the icons to set the Forecolor you want and Bold it.

Now click on OK

You should be set.

BTW, the only kind of formatting you can do on these types of forms, using
code in the Form_Current event, is to Lock/Unlock and Enable/Disable controls.
 
J

jubiiab via AccessMonster.com

I closed access and did it again - now it works??? Thank you very much for ur
time and help. ;)
jubiiab said:
Hi Linq,

when i write this:
[UseSupplier] = -1

I get this message:
The expression you entered contains invalid syntax
Sorry, meant to give you a step-by-step:
[quoted text clipped - 14 lines]
BTW, the only kind of formatting you can do on these types of forms, using
code in the Form_Current event, is to Lock/Unlock and Enable/Disable controls.
 
L

Linq Adams via AccessMonster.com

Glad we could help!

As to your previous post, I've also run into problems, from time to time,
where valid code in Conditional Formatting didn't work until you closed the
form and then reopened it.
 
D

David W. Fenton

If the subform is in Datasheet or Continuous View, as most are,
you cannot do this kind of formatting thru code in the
Form_Current event. You'll have to use the Conditional Formatting
from the Format Menu.

In a datasheet, you can change the color of all the cells at once in
code, but not one cell at a time, unless you use conditional
formatting (which has the drawback of painting very slowly in many
cases).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top