Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Location
    Thailand
    Posts
    4

    Unanswered: passing data to new record (form to form)

    when NotInList data is entered into a form 'FrmA' I need to open a second form 'FrmB' creating a new record and passing on the data entered in FrmA.

    Having the FrmB open to a new record is no problem, but I cannot figure out How to pass to it the data from FrmA

    I'm sure this is a very simple task, but I'm very new to VB. Hope someone can stop me pulling my hair out!!!

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: passing data to new record (form to form)

    Originally posted by spongemonkey
    when NotInList data is entered into a form 'FrmA' I need to open a second form 'FrmB' creating a new record and passing on the data entered in FrmA.

    Having the FrmB open to a new record is no problem, but I cannot figure out How to pass to it the data from FrmA

    I'm sure this is a very simple task, but I'm very new to VB. Hope someone can stop me pulling my hair out!!!
    When your are on Form B , then you can manipulate the data on Form A as follow

    Me.text1= forms!formA.text1
    Me.text2= forms!formA.text2

  3. #3
    Join Date
    Dec 2003
    Location
    Thailand
    Posts
    4
    Thanks for the response. It worked.

    Problem is that I want the second form to open when a not in list condition is met in a combo box of the first.
    When this happens the second form calls up the previous (in list) entry of the combo box and not what in currently visible.

    Do you have a solution to this.

    Thanks

  4. #4
    Join Date
    Dec 2003
    Location
    Thailand
    Posts
    4
    Thanks for the response. It worked.

    Problem is that I want the second form to open when a not in list condition is met in a combo box of the first.
    When this happens the second form calls up the previous (in list) entry of the combo box and not what in currently visible.

    Do you have a solution to this.

    Thanks

  5. #5
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    Use this code in the OnNotInList of the combo on FormA :

    If MsgBox("The value '" & NewData & "' you entered, does not exist yet. Do you wish to add it?", vbQuestion + vbYesNo) = vbYes Then

    DoCmd.OpenForm "FormB", acNormal, , , acFormAdd, acDialog, NewData

    Response = acDataErrAdded

    Else

    Response = acDataErrContinue

    End If

    The argument NewData is automatically the data the user entered in the combo.
    In the OnLoad event of FormB, you put then the following line :

    If Not IsNull(Me.OpenArgs) Then
    Me!txtTextbox = Me.OpenArgs
    End If


    Explanation :
    In the first code (NotInList), you capture the unknown entry from the user and use that entry to put it in the OpenArgs of the formB.
    When you FormB opens, it will detect that its OpenArgs are not empty and will use that value to put it in a textbox. When you then close FormB, code returns to the OnNotInList event of the combo on formA and will add the newly entered value to your combo.

    Try it, you'll see it's quite interesting.

    Greetzzzz

  6. #6
    Join Date
    Dec 2003
    Location
    Thailand
    Posts
    4
    Fantastic!
    That worked like a charm. Why couldn't I see that.

    Thank you VERY much for your help.

    chok dee maak mak

Posting Permissions

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