Flashing subform field. (1 Viewer)

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Ok,

I have a subformt hat is populated by a combo box. When the user selects data from the combo this then lists a customer number, models, and date in the subform. The selection from the combo box executes a query based on customer name in combo box.


The subform displays the models and date purcahsed related to the customer.
There can be more than one model displayed and more than one date.

I am trying to get the date to flash in the sub form if it is over due. I can get a text filed to flash on the main form if the date is already in a field.

Is there anyway that I can get overdue dates in the subform to flash?

I am using on timer and toggling background colour.

Any ideas?

Once again many thanks.

B
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Ok, slightly changed, so that it does not flash, just is higlighted in red.

When I try and run it though I get the following error:

Run time Error '438':
object doesn't support this property or method

the code :

If Me!frmServiceDue.txtNextServiceDue.Value < Date Then

Me!frmServiceDue.txtNextServiceDue.BackColor = vbRed

End If

now what?
 

RuralGuy

AWF VIP
Local time
Today, 03:13
Joined
Jul 2, 2005
Messages
13,825
The syntax to reference a subform control from the main form is:
Me.SubFormControl.FORM.ControlName
Forms are displayed on other forms by means of a SubFormControl. This SubFormControl's name defaults to the name of the form it is displaying but it is not required that it be named the same. If your SubFormControl is named frmServiceDue then your code will be:
Code:
If Me!frmServiceDue.FORM.txtNextServiceDue < Date Then

Me!frmServiceDue.FORM.txtNextServiceDue.BackColor = vbRed

End If
The FORM element need not be capitalized. I just did it to show you what was different. You are probably going to want an Else statement in there to set the BackColor to normal.
 

grnzbra

Registered User.
Local time
Today, 10:13
Joined
Dec 5, 2001
Messages
376
Instead of toggling the background color, toggle the forcolor between what it normally is and the background color. (Of course, you've got to be sure that it always ends up as its normal color and not the background color.)
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
progress sort of,

the error message has gone but the background does not change colour.

Not sure why, guys?
 

RuralGuy

AWF VIP
Local time
Today, 03:13
Joined
Jul 2, 2005
Messages
13,825
Try:
Code:
If CDate(Me!frmServiceDue.FORM.txtNextServiceDue) < Date() Then

Me!frmServiceDue.FORM.txtNextServiceDue.BackColor = vbRed

End If
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Still can't seem to get it to work.

should I put the code on the subform instead?

When the subform is displayed it is in datasheet view, does this mean it is still possible to highlight the dates that are over due?

Thanks again.
 

RuralGuy

AWF VIP
Local time
Today, 03:13
Joined
Jul 2, 2005
Messages
13,825
Hmmm, I don't think you have that much control over a DataSheet view. It is what it is. Whatever you are doing will *only* affect the current record in the SubForm. You may wish to rethink the idea or look into conditional formatting in the subform.
 

namliam

The Mailman - AWF VIP
Local time
Today, 11:13
Joined
Aug 11, 2003
Messages
11,695
You may have to repaint the screen/form

Me!frmServiceDue.FORM.repaint
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
ok is there anyway to still displauy the data but not in datasheet view, so that I can highlight the dates that are overdue?
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Am having a play using continuous from setting will keep you posted.
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Getting closer :D


Just need a little tweak, at present I have the code :

If CDate(Me!frmServiceDue.FORM.txtNextServiceDue) < Date() Then

Me!frmServiceDue.FORM.txtNextServiceDue.BackColor = vbRed

In the On Timer command for the main form. When I open a record that has a date that is over due the date box changes, however all the date boxes on the subform are red.

Hmmmmmmmmmm
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
The other thing is if the date for a service due is empy then I get an error code.

I've tried writing an if statement to only colour the background if service due is not null but I can't get it to work.

something along the lines of If Me!frmServiceDue.Form.txtNextServiceDue <> Null then. . . flash colour.

Else txtNextServiceDue.BackColor = vbwhite.

Again many thanks.
 

namliam

The Mailman - AWF VIP
Local time
Today, 11:13
Joined
Aug 11, 2003
Messages
11,695
If not isnull(Me!frmServiceDue.Form.txtNextServiceDue) then. . . flash colour.

Else txtNextServiceDue.BackColor = vbwhite
end if

But why are you using the main form and not the subform to contain this coding? it is so much easier to not have to handle the subform...
 

RuralGuy

AWF VIP
Local time
Today, 03:13
Joined
Jul 2, 2005
Messages
13,825
Since the control is a TextBox, I believe conditional formatting in the SubForm should achieve the results you desire.
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
no matter where I put the code on the subform, it does not acheive the required result.

I've even tried using:

If txtNextServiceDue.Value < Date Then
txtNextServiceDue.BackColor = vbRed

On the on timer even or on current even for the subform.

Neither make the date change.

AAAAAAAARRRRRRRRRRRRGGGGGGGGGGHHHHHHHHHHH
 

namliam

The Mailman - AWF VIP
Local time
Today, 11:13
Joined
Aug 11, 2003
Messages
11,695
The on current should work *I think*

Also try what RG said... Try using the Conditional formating... that should work allways as well... Using the event to handle this is *old school*
 

Holmes

Registered User.
Local time
Today, 10:13
Joined
Dec 15, 2006
Messages
42
Cheers people, it's working.
Just to finish it off I have selected teh less than statement and put Date() in the filed. Is there anyway to show dates that are out of date by say 7 days?

i.e if date in field is 7 days older or more then change colour?
 

Users who are viewing this thread

Top Bottom