Results 1 to 9 of 9
  1. #1
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153

    Code for Button on MainForm won't function correctly on for the subform

    Ok I've searched and nothing seems to tackle my exact problem, and i've tried modifying codes i've found to fix this problem, but nothing.



    I have a navigation form with subforms.

    Click image for larger version. 

Name:	mainform.PNG 
Views:	17 
Size:	68.0 KB 
ID:	16529Click image for larger version. 

Name:	mainform2.PNG 
Views:	17 
Size:	80.4 KB 
ID:	16530

    The button i'm working code on is the "New Record" button. It works but will not let me set the focus to the field in the subform I want it to go to after it is clicked. in the second image, on the subform itself i have a "Save-New" button that will work and go to the control i want it to. But i'd like to get rid of that button and just use the "New Record" button since it will be at the top of each subform.

    right now the code is



    Code:
    
    Private Sub cmdNewRecord_Click()
    Me.NavigationSubform.Form.Recordset.AddNew
    End Sub
    I've tried adding a set focus and can't get it to work, i would need it to be with an iif because depending on which subform it is it needs to shift focus to a different control.

    Can anyone help me with this?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    With navigation forms you are limited to the Navigation Button's properties. Getting VBA to fire with an on click of the navigation form's buttons is difficult if not impossible. Also, your windows theme appears pink on my monitor.

  3. #3
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    my windows theme is pink.
    they aren't navigation buttons they are command buttons just put onto the navigation form between the navigation buttons and the subform control

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It looks as though you have two layers. So I would guess you have two navigation control names. I do not work with Nav Controls because they have too many nuances and not enough advantages considering my needs.

    I was able to change a value in an unbound control but not able to set focus.
    Forms!frmNavForm1.NavigationSubform.Form.txtSample .Value = 12
    Forms!frmNavForm1.NavigationSubform.Form.txtSample .SetFocus

    This has always been my experience. Some things work and everything is fine and then something that would seem simple is a huge hurdle.

  5. #5
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I have a two lay nav control NavControl0 and then 5, What would you suggest to use instead of a navigation?

  6. #6
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    The button's "name" when accessed from loaded forms in expression builder is Forms![MainForm]![cmdNewRecord] if that helps at all

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The issue I see with the Nav Control is that it is difficult to edit properties of objects and invoke methods. Sure, they give you events like On Click, but you can't always talk to the fields/controls you want to.

    As for the fully qualified name of a second layer, maybe
    Forms![MainForm].NavigationSubform.NavigationSubform2.Form.txtSamp le.Value

    The alternative to the Navigation Control is the Tab Control. If feel you need to be building Web Forms in order to exploit the Nav Control.

  8. #8
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I'm hoping to one day turn this into an actual stand alone program, or access program that I can put on any computer at work.

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by breakingme10 View Post
    I'm hoping to one day turn this into an actual stand alone program, or access program that I can put on any computer at work.
    I do this sort of thing all of the time. The only difference is I do not use the Navigation Control. If you are building desktop apps, apps that are not used over the internet or with SharePoint, then you may not need the Navigation Control.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 06-24-2013, 05:43 PM
  2. Replies: 1
    Last Post: 11-07-2012, 05:31 PM
  3. Replies: 4
    Last Post: 03-30-2012, 01:47 AM
  4. Replies: 1
    Last Post: 11-29-2011, 01:37 AM
  5. Replies: 10
    Last Post: 12-31-2010, 12:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums