Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    660

    Unanswered: Transfer data to another form

    I have a data entry form that has button event, when hit the button, it will open another form. i would like to transfer some of the data in the data entry form to the new form. I use the following code,
    tmpAmount = me.amount.value
    tmpPaymentType = me.Payment.value

    Docmd.OpenForm "fmConfirm",,, stLinkCriteria
    Forms!fmConform!txtAmount =tmpAmount
    Forms!fmConform!txtPaymentType=tmpPayment

    But it didn't show any value on the form.

    Thanks for you help!

  2. #2
    Join Date
    Jul 2006
    Posts
    108
    Code:
    Docmd.OpenForm "fmConfirm",,, stLinkCriteria
    Forms!fmConform!txtAmount =me.amount.text
    Forms!fmConform!txtPaymentType=me.payment.text

  3. #3
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Assuming all vars are string,

    Code:
    Docmd.OpenForm "fmConfirm", , , stLinkCriteria, , ,tmpAmount & "," &  tmpPayment
    If either/both value/s are numeric, you must convert it/them to string [using the CStr() function] in order to insert the comma.

    In the fmConfirm form's Open event, capture the OpenArgs argument and assign the values to the controls you want, as in:

    Code:
    Me.txtAmount = Left(Me.OpenArgs, InStr(Me.OpenArgs, ",") - 1)
    Me.txtPaymentType = Right(Me.OpenArgs, Len(Me.OpenArgs) - InStr(Me.OpenArgs, ",") - 1)
    Hope this helps,

    Sam

  4. #4
    Join Date
    Feb 2007
    Posts
    15
    Hello there,

    Assuming you have two forms (frmSource and frmTarget) paste the following code on click_event (for instance) of cboComboSource.

    Private Sub cboComboSource_Click()
    [Forms]![frmTarget].[cboComboTarget] = [Forms]![frmSource].[cboComboSource].Text
    End Sub
    It works fine.


    Omnia in bonum

    OS

  5. #5
    Join Date
    Mar 2004
    Posts
    660
    Thanks all. Let me try these. Thanks again!

Posting Permissions

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