Highlight the required fields, or the control that has focus

Automatically flag the fields where an entry is required when a Microsoft Access form opens, and automatically highlight (in yellow) the controls as they get focus.

Sponsored Links:

Related Topics

Highlighting current txtBox
The way I have my form designed cosmetically, it is really difficult to see which box the cursor is in if there is no data already entered.

Is there an easy way to either make the cursor thicker or highlight a box when it gains focus and de-highlight when it loses focus?

I.e. change txtBox backfill color on focus and change txtBox backfill color (original color of course) off focus.


Form field validation question
I am trying to highlight fields on a form that the user is required to fill in. The code works on the OnOpen event and if I put it behind a button control. However, no matter where I put the code it will not auto update after the user moves through each field on the form.

What am I missing here? I thought that every time the user changes or enters a value in one of the fields on the report, that would be able to trigger a beforeupdate or afterupdate event.

Not the case. If the field is highlighted yellow and the user enters a value and then leaves the field it still stays yellow.

I am trying to avoid having to put the below code behind every one of the 15 required fields on this form.


Change the appearance of a control by using conditional formatting
Conditional formatting allows you to selectively highlight certain data on your form or report so that it is easier to understand. For example, you might want to format negative numbers in a red font to make it clear that those records need further attention.
You can set conditional formatting for a text box or a combo box control. You can change the formatting based on the control's own value, or you can use an expression to change the formatting based on the values contained in other fields or controls. On a form, you can use conditional formatting to disable a control, and you can cause the formatting of a control to change when the cursor is positioned in that control.
What do you want to do?:
*Apply conditional formatting to a control based on its own value
*Use an expression to apply conditional formatting to one or more controls
*Change the formatting of a control on a form that has the focus
*Remove conditional formatting from one or more controls
*Create alternating row colors on a report


Common SubRoutine to set Controls Back Color
I am using VB 2008 for WinForm Application (exe).

I have 100s of Input Controls on my form (TextBox, ComboBox), now what I want is When the control receives Focus I want it's Back Color set to some color say 'Lemon Yellow' to highlight thecontrol & when it leaves focus set it to it's original.

Writing in Enter Event & Leave Event for every control is not quite a good idea.

So I want a trick to handle this with a single or two events.


Keeping certain controls from getting focus
Is there a way I can keep certain fields from ever getting focus, even if a user clicks over them? I need certain text fields to act like labels basically. I was able to lock them so no data can be entered but I want to take it one step further and keep people from being able to put the focus on those fields.


Current control issue
This is my first post and I hope someone can help me.
I am using Access 2010 and am trying to have a bit of VBA code retrieve the value in a form's current control (text box) regardless of which control has focus. For example the following code specifies the name of the control Invoice Number.

stFile = Me![InvoiceNumber]

How would I modify this to retrieve the data not knowing what control has focus


Set Focus on Control from Navigation Button
I have a Navigation Subform several navigation buttons across the top. When I click on one of the navigation buttons, I would like to ensure that a control on the subform under that button receives the focus. This screen is for barcode entry so I want to make sure the form is ready for action when the user clicks on the nav button.

How do I set focus to the subform control from the navigation button OnEnter event?

Here is my structure:

frmMain --> NavigationSubform --> frmBarcodeEntry --> subfrmBarcodeEntry --> txtBarcodeString

where txtBarcodeString is the textbox control that I want to set focus for.


Set Focus on Control from Navigation Button
I have a Navigation Subform several navigation buttons across the top. When I click on one of the navigation buttons, I would like to ensure that a control on the subform under that button receives the focus.

This screen is for barcode entry so I want to make sure the form is ready for action when the user clicks on the nav button.

How do I set focus to the subform control from the navigation button OnEnter event?

Here is my structure:
frmMain --> NavigationSubform --> frmBarcodeEntry --> subfrmBarcodeEntry --> txtBarcodeString

where txtBarcodeString is the textbox control that I want to set focus for.


GoToControl Macro Action
You can use the GoToControl action to move the focus to the specified field or control in the current record of the open form, form datasheet, table datasheet, or query datasheet. You can use this action when you want a particular field or control to have the focus. This field or control can then be used for comparisons or FindRecord actions. You can also use this action to navigate in a form according to certain conditions. For example, if the user enters No in a Married control on a health insurance form, the focus can automatically skip the Spouse Name control and move to the next control.


How can I add a Highlight to a field on a report?
I have some reports in my database where I would like to be able to Highlight something that I want to stand out.

We were using a program that ran in access before where if we surrounded text with an Asterisk * it would automatically highlight it. Something like this would be ideal for what I want to do.

So if a user puts asterisks around a field in a record it will highlight it.

How can I possibly accomplish this?


SetFocus method...
We have a Form on Access 2007 with two Textboxes and a button and the Form operates on the following code:

[CODE]

If I want to read the value in any Textbox, I have to set focus on that Textbox. Obviously we can set focus only on one control at any instant.

After reading the value in the second Textbox(txtDivNr), I lost focus on the first Textbox (txtPName).
This means, in a long sequence of operations, before reading/writing the value in any control,[Control].SetFocus

Is VBA in Access always like that? Maybe I am mistaken, it used to be simpler. I do not remember of explicitly setting the focus on each control.

Or have I done anything wrong in setting up the Form and the controls? The 'tab' control is working OK when tested. I inserted 'unbound' Textboxes in the Form.


Conditional Formatting on Continuous Sub Form
I'm having a problem with conditional formatting - wondered whether anyone else had experienced this.

I am trying to change the back colour of multiple text boxes on a continuous sub form to highlight particular records if they meet a certain criteria. I know the rule I have written is working OK however it only appears to change the colour once I have clicked onto the field.

it would appear that in order for the colour to change the control needs to have focus - I amunable to set all controls to have focus at the same time but I do need all the controls to be highlighted at the same time?


Required fields in a form
I am trying to make some fields on the form required, I try to make it required on the table used to create the form but since there are records that are missing the info that I now required, every time I accessed old records it does not allow me to get out because there is missing info on the required fields.

I was thinking ifthere is some kind of a macro that will check for required fields before the form is saved.


Required Fields In Form
I've tried several ways of accomplishing this and looked several places on the web but have not been successful in finding a solution.

I have a form where a customer can input data and there are several fields which are required (this requirement is set in the related table).

The Fields on the form that are required are named as follows: txtFirstName txtLastName
txtAddress1
txtCity
txtState
txtZip
txtPhone
cboCategory

Instead of Access giving an error that a certain field is required I would just like to display a generic message of "All Bold Fields are Required." Ideally I would like toaccomplish this by just checking to see if a required field is missing rather than having to list and check each field individually in the form as I have been trying to do:


problematic tabbing behavior on form
I have a form with a number of subforms. I set up the tabbing behavior so that then the user tabs off the last control on a subform, the focus goes to the first control on the next subsequent subform.

I did this using setfocus on the the Exit event of the last control on the subform.

My problem is that when a user want to move the focus elsewhere when they are on that last control on the subform, I.e. clicking some other control, the cursor moves according to the exit event, not as the user expects.

How do I direct the focus through the form without thwarting the user's ability to direct it elsewhere when desired?


allow user to highlight field on form
One form is used to input comments about the the person and has several memo fields. The user wants to be able to highlight a field if the information is important and needs to be highlighted to other users of the system. I cannot use conditional formatting because the decision to highlight the field is made by the user depending on different circumstances.


Setting the focus on a subform
I have a form with 3 subforms. Depending on the value sent to the parent form I want to display certain controls on the subform and hide others. There is one control, a previously mentioned option group that I cannot hide. I get the following message.

"You can't hide a control that has the focus."

So I have tried to move the focus elsewhere like this.

sbfrm_Ballot.Form.txt_Score.SetFocus

Which generates this message.

(This application) "can't move the focus to control 'txt_Score'."

So I'm stuck and open for suggestion.


Setting the focus on a subform
I have a form with 3 subforms. Depending on the value sent to the parent form I want to display certain controls on the subform and hide others. There is one control, a previously mentioned option group that I cannot hide. I get the following message.

"You can't hide a control that has the focus."

So I have tried to move the focus elsewhere like this.

sbfrm_Ballot.Form.txt_Score.SetFocus

Which generates this message.

(This application) "can't move the focus to control 'txt_Score'."


Set Focus to specific tab on a Tab Control
Is it possible to set the focus on a specific tab on a tab control via VBA? My goal is to set the focus to the tab when the form opens.

Different iterations of Me.TabCtl0.Pages.Page1.SetFocus doesn't work. I am unable to find the correct syntax to reference the tab.


set default focus to nothing?
In a pop-up form with several fields, some users are typing in data to the field with the default focus, before they look to see what field they should actually be typing in. The result is incorrectly changed data.

I would like to force the users to choose a field before they start typing. But it seems the default focus is always going somewhere (1st item on tab control). Apparently I can't set it to a label. The best I've been able to do is create a dummy text box & set the default focus there.