Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    17

    Question Unanswered: Carry Textbox Value from 1 Form to Another

    I've got a form, let's call it Form1. Form1 has a text box called txtImportant1 and a command button that will open a new form called Form2. Form2 has a textbox called txtImportant2. I want the value of txtImportant2 to be the same as txtImportant1 as soon as Form2 loads or whenever the user creates a new record using Form2. Form1 will remain open while Form2 is loaded.

    I tried setting the Default Value of txtImportant2 to:
    [txtImportant2]=[Forms]![Form1]![txtImportant1].[Text]
    and I also tried:
    =[Forms]![Form1]![txtImportant1].[Text]
    but those attempts just left me with a "#Name?" in the text box.

    Any and all help *greatly* appreciated!!!

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Use the OpenArgs parameter of the DoCmd.OpenForm method on command1, then use the OpenArgs property of Form2 to obtain the value to assign, probably using the OnCurrent Event.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: Carry Textbox Value from 1 Form to Another

    Originally posted by Nigel_Tufnel
    I've got a form, let's call it Form1. Form1 has a text box called txtImportant1 and a command button that will open a new form called Form2. Form2 has a textbox called txtImportant2. I want the value of txtImportant2 to be the same as txtImportant1 as soon as Form2 loads or whenever the user creates a new record using Form2. Form1 will remain open while Form2 is loaded.

    I tried setting the Default Value of txtImportant2 to:
    [txtImportant2]=[Forms]![Form1]![txtImportant1].[Text]
    and I also tried:
    =[Forms]![Form1]![txtImportant1].[Text]
    but those attempts just left me with a "#Name?" in the text box.

    Any and all help *greatly* appreciated!!!
    And as a special added bonus kiddies I'll post an example using the lovely OpenArgs .... In a form no less ...

    Code:
    Private Sub Form_Open(Cancel As Integer)
        Dim IsOK As Integer
        
        MyUserID = CurrentUser()
        UserIsAdmin = False
        DBConnectionActive = False
        AddingAContact = False
        
        ClosedCheckBox.Value = False
        
        If Not IsNull(Me.OpenArgs) Then
        
            Dim ParmListString() As String
            ' Format:
            '
            ' Parent ID, New Work Order [, Work Order #
            '                           [, Work Order Tbl (, Record #)
            '
            ParmListString = Split(Me.OpenArgs, ",", -1, vbTextCompare)
            WhosMyParent = CInt(ParmListString(0))
            IsNewWO = CBool(ParmListString(1))
            If Not IsNewWO Then WO_Number = ParmListString(2) & ""
    '        Select Case WhosMyParent
    '            Case WOFilterForm
    '                If Not IsNewWO Then WO_Number = ParmListString(2) & ""
    '            Case WOReviewForm
    '                WO_Tbl = ParmListString(2) & ""
    '                If Not IsNewWO Then WO_RecNumber = CLng(ParmListString(3))
    '        End Select
        Else
            MsgBox "This form can only be activated from within the Work Order Review form or the Work Order Filter form"
            Cancel = 1
            Exit Sub
        End If
        
        IsOK = EstablishDBConnection
        If IsOK = 0 Then
            Cancel = 1
            Exit Sub
        End If
        DBConnectionActive = True
        
        IsOK = RetrieveFormSettings
        If IsOK = 0 Then Cancel = 1
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •