Results 1 to 11 of 11
  1. #1
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33

    Navigation Form Subform Code issue

    OK guys and Gals here's my next installment of what has he done now...



    Created a Nav form that works as it should ....to a point I have several tabs that connect to forms and they open as they should BUT I have this one form that I called "HOME" where a greeting message appears to the user once a successful login has been performed. My issue is part of my Greeting msg appears ONLY when you click the "HOME" tab button after the Nav form opens.

    Now the code I'm using is as follows:
    Quote:
    Private Sub Form_Load()
    Me.txtWelcome = Forms![Navigation form]!txtUser.Value


    If IsNull(DLookup("[UserName]", "tblUser", "[UserLogin] = '" & [txtWelcome] & "'")) Then
    Me.welcome = "Greetings" & "..." & Me.txtWelcome
    End If

    End Sub

    Now the code in RED I'm pulling a value from the MAIN form that is to appear in the sub-form "HOME"
    again the problem is NOT that I'm getting the wrong data it's when it appears

    When the Nav form opens the "HOME" tab is a Darker shade of blue than the others and is the form that appears on the screen first like I mentioned earlier, BUT this maybe misleading me to think that focus is placed on this tab at this point .....Only to find out that the focus may be set ONLY when I click it for again that's when the other text data appears which is the "Me.txtWelcome" data (or users name) the "Greetings..." shows up when the form first opens like I want it to.

    Oh one more thing the txt.User.value has data in it after the User successfully logs in. It shows this in the txtUser text box in the Main/Parent Nav form. AND I'm working on the "ELSE" I wouldn't think this was the issue that I'm seeing here now...

    now can someone narrow my lack of knowledge to a more focused area...

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try adding a Me.txtWelcome.SetFocus
    ...at the end of that procedure and see what happens.

  3. #3
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33
    Yeah tried that, but no effect....I was given some information that I'm looking into and that is the Parent form actually loads last and the sub-forms load first...seems that the set focus should be the last thing that happens...If "setfocus" is the fix in some way...

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Absolutely, any SubForms load *before* the MainForm. Where is the txtWelcome control located? The TAB object is just an extension of the Form on which it is located and not really a control in the truest sense.

  5. #5
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33
    The txtWelcome is located in the Navigation subform under the HomeTab (well within the Nav subform seeing how the HomeTab isn't an actual control)....I have the control source set to a text box called txtUser (now... the code in red above I've nz'ed at this time but the issues as to when the data appears is the same for both methods) from the Main/Parent form where the users name appears after the user logs in. The data links correctly it just getting it to appear when the Nav form opens after the user logs in without have to click the "Home Tab" in the Nav form...

    NOW if the subform loads first...is there data in the Main/Parent form (txtUser) at that time to be linked to the subform (txtWelcome) or does the Main/Parent form have to load before the data is linked/available to txtwelcome...and thats why it appears after the clicking of the Home tab it updates the text boxes?..?...in the Nav subform?..?..

    If so then I need to get the correct data in txtUser so when txtWelcome loads it has data to retrieve?.?.?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It sounds like you need code in the Load Event of the MainForm to do what you want. By then all of the SubForm should be loaded and all of the Controls on the MainForm and the SubForms are available to reference.

  7. #7
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33
    I agree, .... thanks

  8. #8
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33
    WAIT...why code in the Load Event in the "MAIN" form when the subform loads first? I take it you mean code that makes the Main form place the data (txtUser) into the txtWelcome (in the subform) and then setfocus (to emulate clicking the Home Tab) which causes the name to appear after the forms loads....

    Hmmm...I'll have to check on how to do that ....currently nothing happens on the load event of the "Main" form except a close command....

    I'll look into it.....

  9. #9
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Expert is already helping you out. I just want add to it.
    My issue is part of my Greeting msg appears ONLY when you click the "HOME" tab button after the Nav form opens.
    In case of Navigation Forms, there is ONLY ONE sub form control and the respective forms get loaded when you click on the navigation button.
    this is from a MSDN article.
    Because the navigation form loads each form as you click the corresponding tab, you can be certain that users see the most current data, without a need for you to create specific code that re-queries the form as users click each tab. This also means that the navigation form does not provide a specific event as you click each tab. Instead, place the load-time code in each form or report Load or Open event handler.
    Here is more info http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx

  10. #10
    johnnyBQue is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    33
    Couldn't figure out the reason why....I'm blaming it on the navigation form.....but I did a work around using the "Detail area" not the subform area and got the results I wanted thanks all that helped.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad to hear you are good to go.

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

Similar Threads

  1. Navigation Form issue
    By johnnyBQue in forum Forms
    Replies: 3
    Last Post: 11-24-2014, 08:39 AM
  2. Replies: 4
    Last Post: 11-06-2014, 05:35 AM
  3. Replies: 12
    Last Post: 10-23-2014, 02:08 AM
  4. VBA/Form Navigation w/SubForm OpenForm Code
    By kennyrogersjr in forum Forms
    Replies: 6
    Last Post: 05-01-2014, 09:59 AM
  5. Replies: 2
    Last Post: 01-27-2011, 08:04 AM

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