EntryForm Default Field for Entry

jcbhydro

Registered User.
Local time
Today, 08:50
Joined
Jul 26, 2013
Messages
187
Good Afternoon,

I have several Entry Forms for inputting data into an Access 2010 Database.
On opening each of the forms, the cursor defaults to the first field in the Tab sequence. This is fine for a new record, but can lead to inadvertent inputting errors in existing records.

Is it feasible to force the cursor to default to the search facility instead of the first field in the Tab sequence when the Form is initially opened?

Any suggestions would be gratefully received.

Regards,

jcbhydro
 
what do you mean by search facility? Provide some examples
 
Yes - on the form load event put in code to set focus to the control you want.

Me.YourControlName.SetFocus

Alternatively or as well, make the search control the first Tab stop.
 
Code:
Private Sub Form_Current()
 If Me.NewRecord Then
   FirstControl.SetFocus
 Else
  SearchControl.SetFocus
 End If
End Sub
Linq ;0)>
 
Thank you CJ London, Minty & Missinglinq for your comments and suggestions.

The suggestion of making the 'search control' the first Tab Stop is very appealing, but I have failed to find a way to achieve it.
The Tab Control dialogue box gives me access only to the Form Header, Detail and Form Footer. The Detail section lists all the existing Tab Fields, but I can't see an obvious way to add 'search control' to that list.

Regards,

jcbhydro
 
I have used the suggested piece of code as an addition to some existing ID Number generating code, but without success.
The code entry now reads;

Private Sub Form_Load()
If Me.NewRecord Then Me.[Member ID] = Nz(DMax("[Member ID]", "[Mail List]"), 0) + 1
End Sub
Private Sub Form_Current()
If Me.NewRecord Then
FirstControl.SetFocus
Else
SearchControl.SetFocus
End If
End Sub

When run this generates a runtime error 424 which states ' object required', and the offending line of code highlighted is; 'SearchControl.SetFocus'.
I am obviously getting something wrong, but what?

regards,

jcbhydro
 
usually means you don't have a control called 'SearchControl'
 
SearchConrol is a made up control name, as is FirstControl - the idea at that point was that you had created a search control not that you wanted to use the inbuilt one.

Perhaps it should have read YourSearchControl and YourFirstControl ...
 
On opening each of the forms, the cursor defaults to the first field in the Tab sequence. This is fine for a new record, but can lead to inadvertent inputting errors in existing records.

You just need to disable/enable editing.

Add a button.

Code:
Private Sub Form_Open(Cancel As Integer)
    Command0.Caption = ""
    Command0_Click
End Sub

Private Sub Command0_Click()
    With Command0
        If .Caption = "Allow Editing" Then
            Me.AllowEdits = True
            .Caption = "Cancel Editing"
        Else
            Me.AllowEdits = False
            .Caption = "Allow Editing"
        End If
    End With
End Sub

Change all Command0's to the name of your button.
 
Thanks Minty,

I had erroneously assumed that First Control and Search Control were defined code words.

Does the inbuilt search facility have such a defined code term?

Regards,

jcbhydro
 
The inbuilt search bar - no not that I'm aware of - and a google didn't get me any hits, so sorry I don't think it possible to use it through VBA.

Happy to be proved wrong by the good and the great on here though.
 
the 'search control' is displayed by setting the form navigation properties to yes. I t is displayed with the record navigation bar.

So far as I am aware they cannot be identified separately and you can only select then via a mouse click (i.e. you cannot navigate to them using the keyboard).
 
Thank you Minty & CJ_London,

I have no problem in displaying the Search Box on the Navigation Bar, but I was hoping to find a method of making the Search Box the default cursor location on opening the form.
Your comments have convinced me that this is not possible.

Thanks again for your contributions.

jcbhydro
 

Users who are viewing this thread

Back
Top Bottom