 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 29th, 2006, 07:51 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
textbox color
Hi I am new in access and I have a lot of questions. I have a form where i put the information of one record that I need, and in the same form i have a subform (same table than the first form) where i have the same information but with all the records of a specific date, i control hours in the most of the fields and what i want to do in all records is that if for example: hour2 > hour1 backcolor the hour2 textbox, until know I can do this but the problem is that if i have 20 records and i put a date in the fist record will put the same color for all the records although the hour1 is > than hour2.
Also i want to know if that color can be reflected in a report?
Could you please help me with this?
I really appreciate all the help you all can give me.
Regards
|
|

September 29th, 2006, 10:57 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I am not so sure about the subform, but I would open it by itself in design view, and then use Format > Conditional Formatting to see if that works.
You can use conditional formatting in the report as well. In the report, you can also go to the Detail section's On Format event and add code like:
Dim iHour1 As Integer
Dim iHour2 As Integer
iHour1 = Me.Hour1
iHour2 = Me.Hour2
If iHour2 > iHour1 Then
Me.Hour2.BackColor = vbRed
End If
for example...
Look up conditional formatting in Help.
HTH
mmcdonal
|
|

September 29th, 2006, 11:32 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, Thanks for your help,
I did try to do what you wrote about the report but at the moment that i run it, show a compile error:
Method or data member not found (and highlight .backcolor =)
Do you know what i am doing wrong???
Also I think that i could use a For cicle to get the color in all records but I do not know if something like "FOR i=1 to end of file" could work.
Thanks again for your help.
Dulce :)
|
|

September 29th, 2006, 11:37 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
.ForeColor will set the font color. I am looking for the back color... hang on...
mmcdonal
|
|

September 29th, 2006, 11:39 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Okay, I used this code and it worked, but I had to set the Back Style to Normal using the text box's Properties dialog box:
Me.Text9.BackColor = vbRed
mmcdonal
|
|

September 29th, 2006, 12:14 PM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Same thing, when i write me.h2. (shows value)it does not have the options as in other ocations to write or choose backcolor. Do you think that I need a especific Reference to be abble to do this???
Thanks
|
|

October 18th, 2006, 02:16 PM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
to access a subform...
[subformBOXname].Form![textBoxName].BackColor = vbRed
note: [subformBOXname] is the name of THE BOX or CONTAINER where the subform is located, not the subform itself
its the name you typed when you added the subform to your form
to find it, open the proporties window
click on the subform ONCE
if you click it once the whole box will be selected and you will see RESIZING abilities
if you click it twice, a dot 5px X 5px in the top left corner of the subform will turn black
you dont want that, you want the other one
I was here but now I'm gone.
I leave this messege to be carried on.
Whoever knew me, knew me well.
Whoever didn't, go to hell.
|
|
 |