Run time error 438

  • Thread starter Sarah at DaVita
  • Start date
S

Sarah at DaVita

I have a form with numerous subforms. Within the subform I am using a
function to hightlight the field the user currently is in. This highlight on
and off is hooked to the got focus and lost focus event on each field the
user can tab to. On the main form I have a button to close the form. When
I click to close I get this error. It points to the hightlight function.
The hightlight function works great when I open each subform individually.
It also works when used in the main form. It only errors when I use the
close button. Can someone help me with this? I think it has to do with the
highlight trying to remove the color when I have clicked out of the form.
Below is what I have hooked to the lost focus.
Function RemoveHighlight()
Screen.ActiveControl.BackColor = vbWhite
End Function
 
D

Dirk Goldgar

Sarah at DaVita said:
I have a form with numerous subforms. Within the subform I am using a
function to hightlight the field the user currently is in. This highlight
on
and off is hooked to the got focus and lost focus event on each field the
user can tab to. On the main form I have a button to close the form.
When
I click to close I get this error. It points to the hightlight function.
The hightlight function works great when I open each subform individually.
It also works when used in the main form. It only errors when I use the
close button. Can someone help me with this? I think it has to do with
the
highlight trying to remove the color when I have clicked out of the form.
Below is what I have hooked to the lost focus.
Function RemoveHighlight()
Screen.ActiveControl.BackColor = vbWhite
End Function

I suppose it could simply be that, as you close the form, there is no longer
an ActiveControl, or the ActiveControl becomes one that doesn't have a
BackColor property. Probably the simplest thing to do is just to trap and
ignore the error:

Function RemoveHighlight()
On Error Resume Next
Screen.ActiveControl.BackColor = vbWhite
End Function
 
S

Sarah at DaVita

I love simple!!! Works great. Thanks so much.

Dirk Goldgar said:
I suppose it could simply be that, as you close the form, there is no longer
an ActiveControl, or the ActiveControl becomes one that doesn't have a
BackColor property. Probably the simplest thing to do is just to trap and
ignore the error:

Function RemoveHighlight()
On Error Resume Next
Screen.ActiveControl.BackColor = vbWhite
End Function


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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

Similar Threads


Top