Hitting TAB at end of form, how go to new, blank form? (1 Viewer)

creolejazz

Registered User.
Local time
Today, 05:40
Joined
Jun 28, 2007
Messages
55
My form contains a combo box that uses a RetrievalField to search records in a table. As I TAB through my form and reach the end of the form, I'd like to hit TAB again and go to a new, blank form. Currently, hitting TAB takes me to the next record in the table. Any help appreciated. Thanks.
 

tarcona

Registered User.
Local time
Today, 05:40
Joined
Jun 3, 2008
Messages
165
Whatever the last thing is on the form....be in a button or a text box....on that field put this code under the On Lost Focus Event:

DoCmd.GoToRecord , , acNewRec
 

stopher

AWF VIP
Local time
Today, 11:40
Joined
Feb 1, 2006
Messages
2,395
Whatever the last thing is on the form....be in a button or a text box....on that field put this code under the On Lost Focus Event:

DoCmd.GoToRecord , , acNewRec
Or, if you specifically only want to trap just the tab key then put the following in the On Key Press event for the last control...

Code:
Private Sub myLastControlName_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Then
    DoCmd.GoToRecord , , acNewRec
End If
End Sub

Chris
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:40
Joined
Feb 19, 2002
Messages
43,302
Open the form in Add mode to do data entry.
 

creolejazz

Registered User.
Local time
Today, 05:40
Joined
Jun 28, 2007
Messages
55
Whatever the last thing is on the form....be in a button or a text box....on that field put this code under the On Lost Focus Event:

DoCmd.GoToRecord , , acNewRec

OK, thanks. I need just a little more help to cross the finish line.

When I copy and paste "DoCmd.GoToRecord , , acNewRec" on the "On Lost Record" property line and try to use it, I get an error message, "cant' find the object 'DoCmd'". Am I supposed to click the "..." instead and paste it in there? If so, do I choose Macro Builder, Expression Builder, or Code Builder? Any step-by-step instructions are appreciated.

REALLY sorry for the newb questions. The more I learn the more I find I don't know.
 

creolejazz

Registered User.
Local time
Today, 05:40
Joined
Jun 28, 2007
Messages
55
Never mind. GOT IT! Thanks so much for the help.
 

missinglinq

AWF VIP
Local time
Today, 06:40
Joined
Jun 20, 2003
Messages
6,423
Glad you got it working, but you really need to get your object names right! The form holds multiple records! You speak of tabbing thru one form and then going to a blank form, when in fact you mean to say tabbing thru one recordand then going to a blank record. This can be confusing to the people trying to help you, as it was to Pat!
 

tarcona

Registered User.
Local time
Today, 05:40
Joined
Jun 3, 2008
Messages
165
Good luck with the rest of your database.
 

stopher

AWF VIP
Local time
Today, 11:40
Joined
Feb 1, 2006
Messages
2,395
Glad you got it working, but you really need to get your object names right! The form holds multiple records! You speak of tabbing thru one form and then going to a blank form, when in fact you mean to say tabbing thru one recordand then going to a blank record. This can be confusing to the people trying to help you, as it was to Pat!
Yes, it's often a challenge getting that handshake between the person asking the question and the person trying to answer it.

But when I read Pat's response it was one I had also considered so I think it is a valid answer. The point being if your are in Add mode then the next record is always going to be a new record assumming the form's Cycle attribute is set correctly. At least that's my thinking and I may be wrong.

Chris
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:40
Joined
Feb 19, 2002
Messages
43,302
For this very reason, people like to separate the data entry operation from the view/edit operation especially when many records are being entered at once. So, you have two options on your menu - Open for Add and Open for View/Edit. That way the form is customized to act appropriately for each use. The additional benefit of using the Data Entry property is that the set of records visible in the form is only the records that have been added since the form was opened. This can be quite helpful if you need to review an entry you just did.
 

Users who are viewing this thread

Top Bottom