Results 1 to 4 of 4
  1. #1
    billperry51 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    2

    Pass data from login page to form with multiple tabs accessed via navigation control

    As you can likely tell when you read what I've written below, I'm quite new to VBA and pretty new to MS-Access too, so please try to go easy on me



    I have a Navigation form with horizontal tabs including: 1) Login; 2) Existing User

    I have a form frm_login mapped to the Login tab on the navigation form
    I have a form frm_existing_user mapped to the Existing user tab on the navigation form
    Tabs on frm_existing_user form include: i) Enter New Data; ii) Update Fields; iii) etc.

    User logs in via the login form; upon successful login, I capture user_name. I want to pass user_name to frm_existing_user form.

    The following code works perfectly except for one issue noted below:
    DoCmd.OpenForm "frm_existing_user"
    Forms![frm_existing_user]![user_name_tbl_transactions] = Me.txt_user_name

    The problem is, this code opens frm_existing_user outside of the navigation form.
    Click image for larger version. 

Name:	MS Access Example.jpg 
Views:	18 
Size:	38.4 KB 
ID:	41546
    If you can see the above image, now there are two open forms: i) Navigation; ii) frm_existing_user after the code I pasted in above executes. I only want a single open form (the navigation form). From there a user can click "Existing User" on the navigation form. Then user can select the appropriate tab on frm_existing_user.

    I'd like for frm_existing_user to open within the Navigation form. However, I'm struggling in my attempt to open frm_existing_user within the navigation form

    Can someone please point me in the right direction?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    The login form need only get the user to the next form if login was successful.
    hold the user ID in a global variable see in every form.
    gvUserID=me.txtUser

    in a module:
    public gvUserID

  3. #3
    billperry51 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    2
    Thanks ranman256 - I created a module:

    Public Function PassUserName() As String
    PassUserName = Me.txt_user_name
    End Function

    Now for the next beginner question - from where do I invoke the code?

    On a form named frm_existing_user, I have a text box with control source = user_name_tbl_transactions
    On that form, I mapped =PassUserName() to user_name_tbl_transactions via the Default Value data property

    That mapping is not setting user_name_tbl_transactions to the value entered into me.txt_user_name.

    What am I doing wrong (or worse yet, not understanding) now?

    Thanks for your help

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,358
    What you probably don't realize is that when using a nav form, only one form is open at a time. When you choose a different tab, one form closes and another opens. It complicates things when trying to pass values from one to another. You can't code the Close event of form A to pass a value to form B because there's no guarantee you won't be selecting form C. There is a BrowseTo property (or is it event?) you could check out as a way of passing a value from one form to another. I've only seen it referred to in forums so I don't know if it's your answer. I don't use nav forms, mainly because of the way they work.
    Last edited by Micron; 04-14-2020 at 04:02 PM. Reason: correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 17
    Last Post: 07-29-2019, 04:24 AM
  2. Login Form pass data to another Form
    By GinaFlanagan in forum Forms
    Replies: 6
    Last Post: 02-11-2019, 12:52 AM
  3. Replies: 2
    Last Post: 11-27-2014, 01:06 PM
  4. Option Control to hide/show page tabs
    By tandridge in forum Forms
    Replies: 3
    Last Post: 12-08-2011, 10:15 AM
  5. Replies: 2
    Last Post: 01-15-2011, 10:56 AM

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