Declaration?

  • Thread starter faapa via AccessMonster.com
  • Start date
F

faapa via AccessMonster.com

Hi

I was wondering if there was a quicker/shorter way of doing this -

I have lots of textboxes, when a user is 'focused' on it, the border width
expands.

I have the following code on each textbox -

Private Sub PM_END_DATE_GotFocus()
Me.PM_END_DATE.BorderWidth = 2
End Sub

Private Sub PM_END_DATE_LostFocus()
Me.PM_END_DATE.BorderWidth = 1
End Sub

I understand it's VERY LONG and tiring so i was wondering if anyone knew how
this can be declared in the beginning of the form?
 
M

ManningFan

Make the Public instead of Private. Then just call them from each
Got/Lost Focus event.
 
D

Dirk Goldgar

faapa via AccessMonster.com said:
Hi

I was wondering if there was a quicker/shorter way of doing this -

I have lots of textboxes, when a user is 'focused' on it, the border
width expands.

I have the following code on each textbox -

Private Sub PM_END_DATE_GotFocus()
Me.PM_END_DATE.BorderWidth = 2
End Sub

Private Sub PM_END_DATE_LostFocus()
Me.PM_END_DATE.BorderWidth = 1
End Sub

I understand it's VERY LONG and tiring so i was wondering if anyone
knew how this can be declared in the beginning of the form?

You could create an independent function in the form's module -- or a
public function in a standard module, if you want to use this on
multiple forms -- like this:

'----- start of code -----
Function AdjustBorder(pWidth As Long)

Screen.ActiveControl.BorderWidth = pWidth

End Function
'----- end of code -----

Then in form design view, you could select all the controls you want to
exhibit this behavor, bring up their joint property sheet (which will
only show the properties that all selected controls have in common), and
enter the following properties:

On Got Focus: =AdjustBorder(2)
On Lost Focus: =AdjustBorder(1)

By setting the event properties themselves to a function expression, you
eliminate the need to create an event procedure for each control.
 
F

faapa via AccessMonster.com

Isn't that the same as i'd have to type each one individually?
 
F

faapa via AccessMonster.com

Sorry to ask an obvious question but how do i bring up the joint property
sheet?

Dirk said:
[quoted text clipped - 15 lines]
I understand it's VERY LONG and tiring so i was wondering if anyone
knew how this can be declared in the beginning of the form?

You could create an independent function in the form's module -- or a
public function in a standard module, if you want to use this on
multiple forms -- like this:

'----- start of code -----
Function AdjustBorder(pWidth As Long)

Screen.ActiveControl.BorderWidth = pWidth

End Function
'----- end of code -----

Then in form design view, you could select all the controls you want to
exhibit this behavor, bring up their joint property sheet (which will
only show the properties that all selected controls have in common), and
enter the following properties:

On Got Focus: =AdjustBorder(2)
On Lost Focus: =AdjustBorder(1)

By setting the event properties themselves to a function expression, you
eliminate the need to create an event procedure for each control.
 
R

RoyVidar

faapa via AccessMonster.com said:
Sorry to ask an obvious question but how do i bring up the joint
property sheet?

It's the property dialog/property sheet - keep it open while selecting,
or hit Alt+Enter afterwards.
 

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