Solved

Go to New record on subform Disabled control

Posted on 2014-09-14
11
402 Views
Last Modified: 2014-09-15
I have a main form "Standards" with a subform (Continuous Form), "NatureofNonConformance" on a tabbed page on the main form. If Non Conformance is selected on the Main form the user is directed to the Subform. Here they enter the details of the non conformance.

I have put the follow code into the On Current event of the subform to prevent users deleting or editing previously entered details ( I cannot disable edits etc on the subform as there are other controls that need to be editable , "ActionCompleteBy")

If Not IsNull(Me!NatureofNC) Then
Me!NatureofNC.Enabled = False
Else
Me!NatureofNC.Enabled = True
End If

I also have a command button on the main form, to enable viewing and editing of enabled controls, which sets focus on the subform.

using:
 Me!NatureofNonConformance.SetFocus


I would like to go to a new record on the subform to enable additional entries, however, when I use
 Me!NatureofNonConformance.SetFocus
DoCmd.GoToRecord , , acNewRec

it takes me to a new record on the main form.
Ideally I would like the command button to take me to the subform on a new record, setting focus on the "NatureofNC" control.

Where am I going wrong?
0
Comment
Question by:SparkyP
[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
  • 6
  • 5
11 Comments
 
LVL 84
ID: 40321624
Try setting focus to a Control on that subform:

Me!NatureofNonConformance.SetFocus
Me!NatureofNonConformance.Form.SomeControl.SetFocus
0
 

Author Comment

by:SparkyP
ID: 40321634
Thanks Scott

That works fine, but takes me to the first record in the subform, rather than a new one. Where would I put the:
DoCmd.GoToRecord , , acNewRec
0
 
LVL 84
ID: 40321635
Not that this has anything to do with your trouble, but you can do away with those If blocks if you're prefer:

Me!NatureofNC.Enabled = Not IsNull(Me!NatureofNC)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 84
ID: 40321637
but takes me to the first record in the subform, rather than a new one
After the second line ... sorry, thought that was understood :)
0
 

Author Comment

by:SparkyP
ID: 40321642
That's what I have being doing, but that takes me to anew record on the main form

 Me!NatureofNonConformance.SetFocus
 Me!NatureofNonConformance.Form.SomeControl.SetFocus
 DoCmd.GoToRecord , , acNewRec
0
 
LVL 84
ID: 40321652
Try setting focus to the FORM object in the first line:

 Me!NatureofNonConformance.FORM.SetFocus
 Me!NatureofNonConformance.Form.SomeControl.SetFocus
 DoCmd.GoToRecord , , acNewRec
0
 

Author Comment

by:SparkyP
ID: 40321660
Scott I get

There is an invalid method in expression when I add Form
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40323158
What's the name of your Subform CONTROL? You must be certain about that ...Subform
0
 

Author Comment

by:SparkyP
ID: 40323213
Scott

Thank you for all your help. Your image made me think about the Tabbed Page. I needed to focus on the Page before moving to the subform and control.

Me!Page243.setfocus
Me!NatureofNonConformance.FORM.SetFocus
 Me!NatureofNonConformance.Form.NatureOfNC.SetFocus
 DoCmd.GoToRecord , , acNewRec

Thanks again for your patience.

Mark
0
 

Author Closing Comment

by:SparkyP
ID: 40323279
Scott

 Thank you for all your help. Your image made me think about the Tabbed Page. I needed to focus on the Page before moving to the subform and control.

 Me!Page243.setfocus
 Me!NatureofNonConformance.FORM.SetFocus
  Me!NatureofNonConformance.Form.NatureOfNC.SetFocus
  DoCmd.GoToRecord , , acNewRec

 Thanks again for your patience.

 Mark
0
 
LVL 84
ID: 40323322
So for others who might find this:

You must focus on the Tab page first, THEN the Subform CONTROL, and finally a control on the subform.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access lists formating 8 50
Ms Access 2010 Setup (Executable file) 4 68
SUBFORM on ACCESS 2013 8 35
Export individual report to pdf 2 41
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

739 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