Using WORD Text Effects with an ACCESS Text box in a form?

R

Robert

I wish to enhance a text box in a form of a database. Some data entry people
just don't read the signs. So if I can either add a flashing backgroud to
the note or add the LAS VEGAS Lights effect, it may get people's attention.
Currently, I just added a background color of RED with black bold font.
However, that is boring. A flashing background such as you can choose via
WORD / Text Effects is what I would like to accomplish.
Anybody have experience in accomplishing this? Thank you,
 
T

Tom Wickerath

Hi Robert,

I don't have any experience doing this, although I experimented a little and come up with
something that might work for you. Open your form in design view, then click on View >
Properties (if the properties dialog is not already open). Make sure the word "Form" is
displayed in the blue title bar of the properties dialog. Click on the Event tab. Set the Timer
Interval value to the number of milliseconds that you want--for example 500 ms to cause a flash
every half second. This event procedure is listed near the bottom of the list.

Then click into the event procedure directly above the Timer Interval, which is labeled On Timer.
Click the ellipses button (the button with the three dots). This should open the code module
associated with this form. You should see the following:

Option Compare Database
Option Explicit

Private Sub Form_Timer()

End Sub


Add the following code, so that you have something that looks like the following. Note: This
example is for a text box named "txtDate". You will need to use the appropriate name for your
text box:

Option Compare Database
Option Explicit

Dim blnFlag As Boolean

Private Sub Form_Timer()

If Me.ActiveControl = txtDate Or IsNull(Me.ActiveControl) Then
Select Case blnFlag
Case True
txtDate.BackColor = 255 ' Red
Case False
txtDate.BackColor = 16777215 ' White
End Select
End If
blnFlag = Not (blnFlag)

End Sub


Add an event procedure to make sure that the background color is reset to white when you tab out
of this textbox:

Private Sub txtDate_LostFocus()
txtDate.BackColor = 16777215 ' White
End Sub


Note: In the first line of code in the Form_Timer event procedure, I found that if I only had:

If Me.ActiveControl = txtDate Then

that the textbox would not flash when one navigated to a new (unsaved) record. So, I added the
check for IsNull. This causes the txtDate field to flash on a new record without regard to the cu
rrent control that has focus.


Tom
____________________________________


I wish to enhance a text box in a form of a database. Some data entry people
just don't read the signs. So if I can either add a flashing backgroud to
the note or add the LAS VEGAS Lights effect, it may get people's attention.
Currently, I just added a background color of RED with black bold font.
However, that is boring. A flashing background such as you can choose via
WORD / Text Effects is what I would like to accomplish.
Anybody have experience in accomplishing this? Thank you,
 
R

Robert

Tom,
Thank you for taking the time to offer your suggesstion. I will give it a
try and let you know how it turns out.
In the meantime, I added a MACRO "do not enter" in which i set the macro for
MSGBOX and then attached the macro to the combo box properties. I set it for
"ON CHANGE". So when a user decides to type in the field that already has
data, it will still allow it, but after they make the change and hit enter,
the message box comes up reminding them that they need to relax, replace
their entry with the original data using the EDIT key and then reminds them
to read the instructions for selecting "ADD NEW DATA" commmand button which
does the same as selecting the next blank record.
 
R

Robert

Tom,
I opened the subform in design view; found the EVENT tab, set the Timer to
500 and then went to the ON TIMER and selected the event builder.
However, I am using ACCESS 2000 and did not see the OPTION COMPARE DATABASE.
it asked me to select to build an event macro, etc.
Should I do this? If so, how do I identify the text box that i want to
flash? Let's say it is TEXT BOX 27. Identify it as such in the name for the
text box?
 
T

Tom Wickerath

Hi Robert,

It sounds like you are trying to prevent a user from changing the selected value in a combo box
for all existing records? Is this correct? If so, you can set the enabled property for the
combo box to No in code if you are on an existing record, but set it to yes if you are on a new
record. This is the beauty of learning and using VBA code. You can do things to really make your
database sing and dance when using code, versus using macros. Use the form's current event
procedure to do this. The current event procedure fires whenever you navigate from one record to
another. It also fires when the form is first being opened. Here is an example for a combo box
named "cboCountry":

Private Sub Form_Current()
On Error GoTo ProcError

If Me.NewRecord Then
Me.cboCountry.Enabled = True
Else
Me.cboCountry.Enabled = False
End If

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, _
"Error in Form_Current event procedure..."
Resume ExitProc
End Sub

Setting the enabled property to false will cause the combo box to look "grayed" out. You can set
the font weight to something more bold, to make it a little easier to read when it is not
enabled. You can also set a locked property for a combo box, instead of the enabled property, but
I don't like the effect so much.

Tom
_______________________________________


Tom,
Thank you for taking the time to offer your suggesstion. I will give it a
try and let you know how it turns out.
In the meantime, I added a MACRO "do not enter" in which i set the macro for
MSGBOX and then attached the macro to the combo box properties. I set it for
"ON CHANGE". So when a user decides to type in the field that already has
data, it will still allow it, but after they make the change and hit enter,
the message box comes up reminding them that they need to relax, replace
their entry with the original data using the EDIT key and then reminds them
to read the instructions for selecting "ADD NEW DATA" commmand button which
does the same as selecting the next blank record.

_______________________________________
 
T

Tom Wickerath

Hi Robert,
However, I am using ACCESS 2000 and did not see the
OPTION COMPARE DATABASE. It asked me to select
to build an event macro, etc.

Okay, this means that you not have a check placed in an option that reads "Always use event
procedures". This option is found under Tools > Options on the Forms/Reports tab. If you place
a check in this option, then you will not be presented with the dialog that includes the
following three options:

Expression Builder
Macro Builder
Code Builder

A check in this option is the same as automatically selecting the Code Builder option. Your
choice....either leave this option unchecked and select code builder, or place a check in this
option and you won't be prompted again.

Once you open the code module behind a form, you should see Option Compare Database at the top of
the module. You may or may not see the next line of code, which reads Option Explicit. If you do
not see the very important Option Explicit, then click on this link to learn how to configure
your VB editor so that you will always get this line inserted on new modules:

http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions


how do I identify the text box that I want to flash?

In form design view, click on View > Properties (if the properties dialog is not already
displayed). Then select the textbox in question with your mouse. You should see the name of the
textbox in the blue title bar of the properties dialog. I suggest using a descriptive name, such
as txtDate, for a date value or txtCountry for a country, etc. You really don't want a control by
the name of TEXT BOX 27. If you are reading the following VBA code, you likely wouldn't know
which text box on a form was being effected:

TEXT_BOX_27.BackColor = 255 ' Red or
TEXT_BOX_27.Enabled = False

I suggest that now is a good time to start using naming conventions. Good naming practices
include not using spaces in the names of any objects or controls. Here are some articles that you
can read on the subject:

Commonly used naming conventions
http://www.mvps.org/access/general/gen0012.htm
http://www.xoc.net/standards/default.asp

Special characters that you must avoid when you work with Access databases
http://support.microsoft.com/?id=826763

Reserved Words in Microsoft Access
http://support.microsoft.com/?id=286335



Tom

PS. You indicated that you are a retired Navy Chief. The father of a friend of mine is a
retired Captain of an attack class submarine. I find it very interesting to hear some of his
stories. If you send me a personal e-mail message, I will reply with his name. My e-mail address
is fairly easy to derive from this posting. Please do not post your real e-mail address to this
newsgroup.
____________________________________


Tom,
I opened the subform in design view; found the EVENT tab, set the Timer to
500 and then went to the ON TIMER and selected the event builder.
However, I am using ACCESS 2000 and did not see the OPTION COMPARE DATABASE.
it asked me to select to build an event macro, etc.
Should I do this? If so, how do I identify the text box that i want to
flash? Let's say it is TEXT BOX 27. Identify it as such in the name for the
text box?

____________________________________

2nd attempt to post. The first time I posted this message, it showed in my newsreader for less
than a minute. Then, it just disappeared, with a message that indicated that the message was too
old and could not be retrieved from the server! Sorry if anyone sees this message repeated in
their newsreader....
___________________________________________


Hi Robert,

I don't have any experience doing this, although I experimented a little and come up with
something that might work for you. Open your form in design view, then click on View >
Properties (if the properties dialog is not already open). Make sure the word "Form" is
displayed in the blue title bar of the properties dialog. Click on the Event tab. Set the Timer
Interval value to the number of milliseconds that you want--for example 500 ms to cause a flash
every half second. This event procedure is listed near the bottom of the list.

Then click into the event procedure directly above the Timer Interval, which is labeled On Timer.
Click the ellipses button (the button with the three dots). This should open the code module
associated with this form. You should see the following:

Option Compare Database
Option Explicit

Private Sub Form_Timer()

End Sub


Add the following code, so that you have something that looks like the following. Note: This
example is for a text box named "txtDate". You will need to use the appropriate name for your
text box:

Option Compare Database
Option Explicit

Dim blnFlag As Boolean

Private Sub Form_Timer()

If Me.ActiveControl = txtDate Or IsNull(Me.ActiveControl) Then
Select Case blnFlag
Case True
txtDate.BackColor = 255 ' Red
Case False
txtDate.BackColor = 16777215 ' White
End Select
End If
blnFlag = Not (blnFlag)

End Sub


Add an event procedure to make sure that the background color is reset to white when you tab out
of this textbox:

Private Sub txtDate_LostFocus()
txtDate.BackColor = 16777215 ' White
End Sub


Note: In the first line of code in the Form_Timer event procedure, I found that if I only had:

If Me.ActiveControl = txtDate Then

that the textbox would not flash when one navigated to a new (unsaved) record. So, I added the
check for IsNull. This causes the txtDate field to flash on a new record without regard to the
current control that has focus.


Tom
____________________________________


I wish to enhance a text box in a form of a database. Some data entry people
just don't read the signs. So if I can either add a flashing background to
the note or add the LAS VEGAS Lights effect, it may get people's attention.
Currently, I just added a background color of RED with black bold font.
However, that is boring. A flashing background such as you can choose via
WORD / Text Effects is what I would like to accomplish.
Anybody have experience in accomplishing this? Thank you,
 

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