Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Continuous form navagation in Access 2010

Posted on 2011-03-10
14
Medium Priority
?
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

610 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