Set the focus on the first field in a form whenever a record is viewed

In Access 2003/XP/2000/97, I have a control button to "Add a New Record" on a form. I realized that when I clicked on it, even though a new record comes up, the cursor does not go directly to the first field of data entry. How can I get the cursor to move to the first field on the form?

Sponsored Links:

Related Topics

Set the focus on second field in a subform whenever a record is viewed
In Access 2003/XP/2000/97, I have a form and a subform (master/detail relationship). The main form is in the Form Header section while the subform is in the Detail section. The problem is every time I add a new record, the cursor won't go to the second field in the subform.


Reverting Field Focus
First I need to setfocus to that field. Problem is that when this script is done, I want the form to be otherwise unchanged,including the focus being on the original field (so that I don't disorient the user).

How do I write VBA code to remember what field originally had focus, and then to set focus back to that field.


Set the focus to the top of the form that has a tabcontrol
I have a form which consists of a tab control. When users switch between tabs, I want to set the focus of the entire form to the top of the form each time instead of where they let the form on their previous visit.

I tried to set the focus to the top of the form by using the following:

Me.StudentID.SetFocus

I also read somewhere in one of the forums I can set the focus first to the mainform by using

Forms![MainFormName].Set focus

But I can't figure out where it should go?


Load form from datasheet and set focus
I am trying to load a double clicked record within a datasheet on the form. I am using the following to load the record:
....
This is kind of funky. sometimes when I double click the record it loads the form blank on a new record instead of allowing us to edit the matching record in the original entry form. The other issue is, the .setfocus is acting up too.

the form gets loaded but then it goes back to the form the record was double clicked on instead of stating focus on frm_error_entry. I verified there is no code on load/focus etc that would be throwing focus back to the original form.


Add New Record and set focus in the first field
When opening a form, I want to add a new record and set focus in the first field.


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.


Setting focus on a tabbed form
I have a form with 1 tab control, containing 4 pages. When the form is opened, the focus is set for the first field on page 1. If I click on any of the other pages, then go back, and click on page 1, I cannot get the focus set to the first field on page 1. It always goes to the second field, and since the first field has not data, I receive an error. Within the properties of page 1, on the on click event, I've tried setting the focus, but it's not working


Set Focus Issues in Form VBA
I have a subform that I have set some code in the on open event of the main form.

The code sets some controls (fields) to enabled = False but I get an error message about can't do this when the it is on focus.

How can I get it Off Focus when the main form is opened?

Can I set some cmd button to have focus and allow my code to work


Setfocus to Main Form after Previewing Report
- I have a command button on a main form. The command button opens a report. Once the report is viewed and closed, the main form loses focus. How can I set focus back to a control on the main form?


Form Focus?
I have a very simple program. 2 tables and 1 form. The form is used to look up and display data from the tables. I set the form up to be a popup and I minimize the Access database with [DoCmd.RunCommand acCmdAppMinimize].

I also set the focus to the input textbox since it is the only box that can be typed into. Everything works great. The cursor shows up and blinks in the input textbox, but when I try to enter something in the input textbox nothing happens. The form does not have focus so the typing does not show up until I click on the form or the textbox with the mouse and the form regains focus.

I have tried everything I can think of to get the form to have focus when it pops up but to no avail. Anyone have any ideas on how to fix this or is it just a pipedream on my behalf?


Dsum criteria to return current month results based on date in another field
Sorry if I missed this in another post, bit didn't see it when searched for.

I have a form that has a [EntryDate] date/time field formatted as LongDate. This form also contains several currency formatted fields.

I am using DSum to calculate one of these currenct fields but am wanting to show only the results for the month and year that equals that of the currently viewed record based on the [EntryDate] field of the currently viewed record. Is this possible, and how would that criteria lo


Entering duplicate data in Form
I find myself entering the same data in some particular fields from one record to the next. (In a form view). What I would like to be able to do, with a few keystrokes, enter the same data for any field that that has focus that would match what was entered into that same field on the previous record. For example, if I am entering data for record #107 and the [PhoneNumber] in the same as the previous record (#106) [PhoneNumber] record rather then type the phone number again it could be entered again with a few keystrokes. I would like this option for entering any, all or none of the fields in the record I am working on and exercising that option in each field as it has focus. Again, whatever field I was going to repeat, it would always be the same as that same field in the previous record. On more thing, I may sometime need to make a minor change in a repeated field value without changing the field that is being repeated


Load form from datasheet and set focus
I am trying to load a double clicked record within a datasheet on the form. I am using the following to load the record:

Private Sub assoc_name_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_error_entry"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![frm_error_entry].SetFocus End Sub

This is kind of funky. sometimes when I double click the record it loads the form blank on a new record instead of allowing us to edit the matching record in the original entry form. The other issue is, the .setfocus is acting up too. the form gets loaded but then it goes back to the form the record was double clicked on instead of stating focus on frm_error_entry. Is there a better way to take care of this? I verified there is no code on load/focus etc that would be throwing focus back to the original form


Datasheet subform to Select Main Form Record -Datasheet losing focus after selection
It's actually a Main form with 2 nested subforms. Selecting the datasheet record subform3 selects the corresponding record in the Form of subform2. After clicking on the datasheet to select the record, the focus automatically goes to the first record.

I can click on the same datasheet record to regain the focus. I've been searching, but this activity is not very common. I just want to click on the datasheet record and have it stay focused on that record. The code I have used for the on_click of subform3 is:


Calculated (vba) textbox in access form empty with value
I have a form in access that has several textboxes with calculated values (VBA function, returns variant(always currency) value). When I open the form (and other forms that use calculated fields like this), it won't show the contents of the textbox. The textbox always has a value (either 0,00 (valuta type field) or calculated price (subtotal, BTW (taxes) and total price)).
It starts showing the values in the textbox when it gets the focus (cursor on it/click on it) for every field, until I go to the next/previous record or close the form. When the form is closed and later reopened or gone to the next record (see onCurrent function), if the calculated field has focus when switching records/(re)opening only the field with focus shows it's value. All other calculated fields keep hiding their values until they get focus (once) again.

Anybody knows of this problem and how to solve it (permanently)?

BTW, I'm using windows vista 32-bit with Access 2007 on this project


Allow Read or Update dep on record
I have a subform in a form, the subform is a datasheet based on a query, one of it's field is a userid field tracking who created the record.

User wants the ability to update records they created, and read only records created by others.

My intention is to make the form enabled or disabled depending on which record gets the focus.

First I tried <On Current> event of the subform, got error 2164 - "You can't disable a control while it has the focus."

Next I tried <On Enter> and <Got Focus> event of the subform fields to disable the form, that gave me the same error


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.


SetFocus to a Form control when cursor is in Split Form datasheet
I have a Main form with a Split Form view.

I have an OnCurrent event that runs when the user selects a different record in the Split Form.

The first part of the OnCurrent event is as follows:

1) [Forms]![f_MainTripForm_Admin].SetFocus
2) [Forms]![f_MainTripForm_Admin]![TripStartDate].SetFocus

However, the focus is staying on the TripStartDate field in the SplitForm, and not moving to the TripStartDate field in the Main form as desired.

I need to move the focus to the TripStartDate control on the form so that I can run the remainder of the OnCurrent event which shows or hides various controls on the Main form depending on the type of record the user is viewing.

Otherwise, the focus could be on a control that I am trying to hide and I will get the "Can't hide a control that had the focus" error.


Passing focus to subform.....
I for the life of me can not seem to get the focus to pass to my subform. I have a main form with a few buttons and a datasheet subform. User enters data into the subform and clicks submit on the main form and the data is pushed to the appropriate tables. Need the foucus to be sitting in the 1st record, second column when the form opens. I've tried a number of things and can't seem to get it right. As usual, any and all comments are appriciated.

Main Form = CELL_ROOM_1_ACID
Sub Form = CELL_ROOM_1_ACID_SUB
Focus field on Sub Form = fldConductivity


Setting Focus to Field on Continuous Subform
so I have a subform and I want to set focus to a combo box on the subform after lost focus of the combo box field. I need for the user to make a selection from the combo box before moving on. I am placing the code on the LostFocus event procedure of the subform and it works as far as giving me my message but it WILL NOT set focus back to that field no matter what I try. Here is my coding and I am also providing screen shots.

Private Sub defWC_LostFocus()
If (IsNull(defWC) And Len(defAttCode)) > 0 Then
MsgBox "Please enter Who Committed the error.", vbOKOnly, "Validation"
Me.defWC.SetFocus
Exit Sub