Results 1 to 2 of 2

Thread: pass the value

  1. #1
    Join Date
    Sep 2005

    Unanswered: pass the value

    I have 2 forms

    I made 1 textbox in one form, second textbox in another form. I want to pass one value in one textbox to another textbox of another form.

    How can I write the code? Thanks.

    Textbox: 200

    //will appear the value
    Textbox: 200

  2. #2
    Join Date
    Nov 2003
    First will want to make sure the second Form is infact loaded and ready to receive data. To do this you can use the IsLoaded function (below). Place this function into a database code module.

    Public Function IsLoaded(ByVal strFormName As String) As Integer
       ' Returns True if the specified form is open in Form view or Datasheet view.
       Const conObjStateClosed = 0
       Const conDesignView = 0
       If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
    	  If Forms(strFormName).CurrentView <> conDesignView Then
    		 IsLoaded = True
    	  End If
       End If
    End Function
    The code you would use is below. Replace the ficticious form and field names (highlighted in red italic) with the proper ones. Where you place this code is up to you depending upon your specific application. This code is assumed to be running from Form1:

    If IsLoaded("Form2") Then 'If Form2 is loaded then
    ' Place the data in Textbox on Form1 to Textbox on Form2.
    Forms![Form2].[F2_TextBoxName] = Me.F1_TextBoxName
    ' Do Nothing...or whatever else you want.
    End If

    Self Taught In ALL Environments.....And It Shows!

Posting Permissions

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