Solved

Continuous form navagation in Access 2010

Posted on 2011-03-10
14
308 Views
Last Modified: 2012-05-11
I have form with a subform set to continuous mode.  I have a second form that is a search form that the user uses to search and the searched number is stored in txtSearchNum.  This number is used to populate a row in the database.  The code below works as long as the new record does not have the focus.  If the focus is in the new record the program stops at the line RunCommand acCmdRecordsGoToNew.  Is there a way to check to see if the focus is in the new record so I can prevent this line from executing?

    If Not IsNull(Me.txtSearchNum) Then
        Me!Child808.SetFocus
        RunCommand acCmdRecordsGoToNew
        Me!Child808!cmbJob = Me.txtSearchNum
    End If
0
Comment
Question by:threeieng
  • 7
  • 5
  • 2
14 Comments
 
LVL 75
ID: 35103497

Sure ... like so:

    If Not IsNull(Me.txtSearchNum) Then
        Me!Child808.SetFocus
       If Me.NewRecord = False Then RunCommand acCmdRecordsGoToNew
        Me!Child808!cmbJob = Me.txtSearchNum
    End If

mx
0
 

Author Comment

by:threeieng
ID: 35103743
When I tested the supplied statement it doesn't work.  My subform displays 8 records.  If the focus is in the new record it works like I want.  If the focus is in one of the 8 records, it just replaces that record.  I need the focus to shift to the new record before the update.

Thanks,
0
 
LVL 75
ID: 35103834
"Is there a way to check to see if the focus is in the new record"

Yes ... by using the NewRecord property of the Form to test if you are at the New Record position.  The reason you get the error is because you are at the New Record position ... and the DoCmd fails for that reason.

"before the update.'
What update are you referring to ?

mx
0
 

Author Comment

by:threeieng
ID: 35104040
Me.NewRecord is True no matter if the focus is in the new record or in an existing record.
0
 
LVL 75
ID: 35106194
Sorry ... but that's not really possible.  Something else is going on ...

mx
0
 
LVL 84
ID: 35107767
What type of Control is "Child808"? Is is a Combo, Texbox, Subform, etc etc
0
 

Author Comment

by:threeieng
ID: 35107830
It is a subform.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 84
ID: 35107958
Try setting focus to the Subform, then to a CONTROL on that subform. For example, your subform contains a control named "cmbJob". Set the focus to that control:

Me!Child808.Form.SetFocus
Me!Child808.Form.cmbJob.SetFocus

If Me.NewRecord = False Then RunCommand acCmdRecordsGoToNew

Note also that you should refer to controls on your subform like this:

Me!Child808.FORM.cmbJob = Me.txtSearchNum

"Child808" is the name of your Subform CONTROL. That control contains a SourceObject (which is a Form), and you must refer to that Form in order to work with the Controls and such on that form.


0
 

Author Comment

by:threeieng
ID: 35108505
When I add Form to the .SetFocus I get an error that says "There is an invalid method in an expression."
0
 
LVL 75
ID: 35109772
A variation on what LSM posted


Me!Child808.SetFocus  ' ** changed this

Me!Child808.Form.cmbJob.SetFocus

If Me.NewRecord = False Then RunCommand acCmdRecordsGoToNew

Note also that you should refer to controls on your subform like this:

Me!Child808.FORM.cmbJob = Me.txtSearchNum
0
 

Author Comment

by:threeieng
ID: 35127850
Same as before.
"Me.NewRecord is True no matter if the focus is in the new record or in an existing record."
0
 
LVL 75
ID: 35129899
Can you:

1) Compact & Repair (*** to shrink the size),

2) Zip up the MDB (*** to further shrink the size)

3) Attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course.

4**** And please give a clear explanation of exactly how to reproduce the problem or what you are trying to do.

How to upload:
http://www.experts-exchange.com/Community_Support/General/A_2790-How-do-I-attach-a-file-at-Experts-Exchange.html

mx
0
 

Accepted Solution

by:
threeieng earned 0 total points
ID: 35130577
I figured out a way to accomplish what I wanted.  I simply read the value from the combo box and store it to a temporary variable.  If the temp value is null then I move to the new record.  Works just fine.

Thanks for all the input.
0
 

Author Closing Comment

by:threeieng
ID: 35170933
Accepted own solution because other solutions did not work.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now