Solved

Continuous form navagation in Access 2010

Posted on 2011-03-10
14
335 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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
 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

816 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

9 Experts available now in Live!

Get 1:1 Help Now