trouble passing data to a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neekos
    New Member
    • Aug 2007
    • 111

    trouble passing data to a form

    Hello all.

    I have a form that i want to open when i close the current form. On the new form, i need a field to populate with data from the form im closing. Is this even possible?

    Here's my code that isnt working:

    [CODE=vb]Private Sub Form_Unload(Can cel As Integer)
    Dim passNum As Variant

    passNum = Me![ProCC #] 'errors out here "object doesnt support property or method

    DoCmd.OpenForm "frmProcess "

    Forms!frmProces s![ProCCnum] = passNum

    End Sub[/CODE]

    any ideas?
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Originally posted by Neekos
    Hello all.

    I have a form that i want to open when i close the current form. On the new form, i need a field to populate with data from the form im closing. Is this even possible?

    Here's my code that isnt working:

    [CODE=vb]Private Sub Form_Unload(Can cel As Integer)
    Dim passNum As Variant

    passNum = Me![ProCC #] 'errors out here "object doesnt support property or method

    DoCmd.OpenForm "frmProcess "

    Forms!frmProces s![ProCCnum] = passNum

    End Sub[/CODE]

    any ideas?
    Hi there,

    You can use the openArgs property of a form to pass information to it when using the DoCmd.OpenForm command.

    Here's an example... In this example the first form has a textbox called txtData. This holds the data I'd like to pass to the form I'm opening called frmTest.

    [code=vb]
    Private Sub Form_Unload(Can cel As Integer)

    DoCmd.OpenForm "frmTest", , , , , , Me.txtData

    End Sub
    [/code]

    Now on the Load Event of frmTest I set the control I want displaying the passed data to the OpenArgs property of the form. In this case I'm using a textbox called txtTextBox.

    [code=vb]
    Private Sub Form_Load (Cancel As Integer)

    Me.txtTextBox = Me.OpenArgs

    End Sub
    [/code]

    This may not solve your error however. This is merely an example to pass data from one form to another.

    To help solve your error could you explain what kind of control Me![ProCC #] is? i.e. a combo box, list box, text box etc,

    Comment

    • Neekos
      New Member
      • Aug 2007
      • 111

      #3
      OpenArgs worked...thanks !!

      Comment

      Working...