Results 1 to 6 of 6
  1. #1
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60

    Auto-filling textboxes with Value from other form

    I have a Logon form that contains 2 textboxes: "UserID" and "Password"



    I have a Work Order form that has an "Opened By" field.

    I would like to auto-fill the "Opened By" field with the "UserID" entered on the Logon form.

    How can I do this? Detailed explanation greatly appreciated. I've tried several things and can only get the #Name? response.

    Thank you!

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    A number of ways to do this, of course! Is the order of events here

    • Sign in to Logon Form
    • Open WorkOrder Form
    • Enter New Work Order

    If so, something like this, using the OpenArgs parameter to pass the UserID:

    In the Logon Form

    Code:
    Private Sub OpenWorkOrderForm_Click()
    
    DoCmd.RunCommand acCmdSaveRecord
    
    If Not IsNull(Me.UserID) Then
      DoCmd.OpenForm "WorkOrderForm", , , , , , Me.UserID
     Else
      MsgBox "A User ID Must Be Entered First!"
     End If
    
    End Sub


    In the WorkOrderForm

    Code:
    Private Sub Form_Load()
    
    If Not IsNull(Me.OpenArgs) Then
      DoCmd.GoToRecord , , acNewRec
      Me.[Opened By] = Me.OpenArgs
     End If
    
    End Sub

    The Square Brackets are only needed around the Opened By Control name if there is a Space in the name.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    The order of events is as follows:

    • Sign in to Logon Form
    • Auto opens Main Menu Form
    • Select "New Work Order" command button to open NewWorkOrderForm
    • Enter New Work Order

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Then use the same technique to 'move' the UserID to the Main Menu Form and then again to the Work Order Form.

    An alternate in 2007/2010, although I've never used it, would be the assigning the UserID to one of the new TempVars. I believe that this is the correct syntax, but if you have problems, simply use the Access Help.

    To assign a value to a TempVars

    TempVars.Add "UserName", Me.UserID

    To use the TempVars, in the Work Order Form, for a New Record
    Code:
    Private Sub Form_Current()
     If Me.NewRecord Then
      Me.[Opened By] = TempVars!UserName
     End If
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    Got it working! Thank you so much!

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Auto display name when filling form
    By mohiahmed in forum Forms
    Replies: 3
    Last Post: 01-22-2012, 02:35 PM
  2. Problem filling textboxes from combobox
    By reidn in forum Forms
    Replies: 1
    Last Post: 06-23-2011, 05:06 PM
  3. Problemss filling textboxes from combobox
    By reidn in forum Programming
    Replies: 13
    Last Post: 06-23-2011, 01:48 PM
  4. Auto filling a form from table
    By JoScSM in forum Forms
    Replies: 1
    Last Post: 11-02-2010, 08:09 AM
  5. Auto filling form fields
    By adamch29 in forum Forms
    Replies: 1
    Last Post: 07-25-2007, 06:22 PM

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