Set focus when new form opens

AlanW

Registered User.
Local time
Today, 07:55
Joined
Aug 11, 2001
Messages
25
I have a ‘Not In List’ event that opens a new form and inserts the new data into the first control/field and sets focus to that control. This works fine but I want the focus to be set to the next control so that the first control with the new data doesn’t get overwritten. I’ve tried ‘set focus’ and ‘goto control’ code in the ‘on load’ event of the new form but it doesn’t work (or I’m doing it wrong). Can anyone tell me how to set the focus to the next control?
 
Hi

are you populating your first field via openargs? If yes this is how i do it on the OnLoad event and works fine:

Code:
If Me.OpenArgs <> "" Then
Me.FieldName1 = Me.OpenArgs
Me.FieldName2.SetFocus
End If

replace fieldname1 & 2 with the actual fieldnames of your controls.
 
Simply change the tab order? right click your form and click tab order. Change it to suite your needs.
 
Changing the Tab order doesn’t work

The new data is sent from the previous form to the new form using the folllowing code in the NotInList event:

DoCmd.OpenForm "NewClient"
Forms!NewClient![File Number] = NewData


The ‘New Form’ OnLoad Event has the following code to select a new record but it doesn’t set focus to the Client_Surname field

DoCmd.GoToRecord , , acNewRec
Me.Client_Surname.SetFocus

Any ideas?
 
DoCmd.OpenForm "NewClient"
Forms!NewClient![File Number] = NewData

put DoCmd.OpenForm "NewClient" , , , , NewData

then in the onload of your form put:

Code:
If Me.OpenArgs <> "" Then
Me.[File Number] = Me.OpenArgs
Me.Client_Surname.SetFocus
End If
 

Users who are viewing this thread

Back
Top Bottom