Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting data from FormA!Combobox1 to FormB!textbox (Access 2k Win 2k)

    Dear All

    I've got a little, OK BIG, challenge for our local gurus. A while ago I was helped out by Dave Willet and Hans in order to get data from one open form into another form opened from by an action in the original, example: -

    Form A has 123 in text box 1, Form B opens and FormB!textBox1 = FormA!TextBox1, this was cool, and I got FormB to recognise if FormA was open (thanks guys) and only 'look' for the data if it was.

    I'm now trying to do something similar, but working with a combo box in FormA and using the NotInList acion to open FormB and add the non existent record to the table, this works fine (another tip from here). My problem startts due to the fact that one of the users can't manage to type the same thing into two separate boxes, I've explained the error several times and the mistake is still costing me hair. So I'm hoping to make FormB get the data from teh ComboBox in FormA. My problem starts here, the combo box does not actually contain any data, it looks like it does, but the data entered is not in the supporting table so I guess it's in Access limbo. Is there any way of getting the data out of this ComboBox??

    Here's what I'm using so far, it runs from the on open event in FormB: -

    Dim parameter1 As String
    Dim parameter2 As String


    If SysCmd(acSysCmdGetObjectState, acForm, FormA) = True Then
    parameter1 = Forms!FormA!Combo1
    me.TextBox1 = parameter1
    Else
    End If

    All forms are opened with modal and pop up set to yes, to stop folk from modifying the forms accidentally, or not following the correct steps.

    I have a feeling that this is either not possible, or I'm approaching the problem from the wrong direction.

    Any help at all would be appreciated.


    Thanks

    Ian

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Getting data from FormA!Combobox1 to FormB!textbox (Access 2k Win 2k)

    Hi Ian,

    If I understand you correctly, you open FormB from the NotInList event of the combo box Combo1 on FormA. One of the arguments of the NotInList event is NewData; this is the text entered by the user that does not occur (yet) in the list. You can pass this to FormB in the OpenArgs argument of DoCmd.OpenForm:

    Private Sub Combo1_NotInList(NewData As String, Response As Integer)
    On Error GoTo Err_Sub

    If MsgBox("The entry ''" & NewData & "' does not occur in the list. Do you want to add it?", _
    vbYesNo + vbQuestion + vbDefaultButton2) = vbYes Then
    DoCmd.OpenForm "FormB", , , , , acDialog, NewData
    ' Set Response argument.
    Response = acDataErrAdded
    Else
    ' User cancelled; undo edit.
    Response = acDataErrContinue
    Combo1.Undo
    End If

    Exit Sub

    Err_Sub:
    MsgBox Err.Description
    End Sub

    You can pick up OpenArgs in the OnLoad or OnOpen event of FormB. Using the variables you mention:

    parameter1 = Me.OpenArgs
    Me.TextBox1 = parameter1

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting data from FormA!Combobox1 to FormB!textbox (Access 2k Win 2k)

    Hans

    Thanks, guess I've got to keep going in order to find a challenge for you <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    My hair follicles send their gratitude <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    Ian

Posting Permissions

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