Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    233

    Unanswered: push colm 1 & colm 2 values from cbo to sub form txtboxes

    i have a form with a combo box, it has 2 fields the 1st is hidden the second is visible

    I would like to take the 2 values and put them into 2 txtboxes on my sub form, the subform is set to data entry, there is currently no data in the subform table, i would like to filter the subform if there are any records, or add a new rec if the ID from the cbo doesnt exist in the subform table

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    You really haven't given a lot to go on here.

    I would like to take the 2 values and put them into 2 txtboxes on my sub form
    [code]
    Dim Ctrl1 As Control, Ctrl2 As Control

    Ctrl1 = Forms("youMainFormName")("yourSubFormName").Form.TheFirstControlNameInSubForm
    Ctrl2 = Forms("youMainFormName")("yourSubFormName").Form.TheSecondControlNameInSubForm

    Ctrl1 = Me.myComboBoxName.Column(0)
    Ctrl2 = Me.myComboBoxName.Column(1)

    i would like to filter the subform if there are any records, or add a new rec if the ID from the cbo doesnt exist in the subform table
    Whoa...first you want to fill the contents of two fields within the SubForm which in essense is starting a new record (no?) .... then you want to Filter the SubForm for Records? I'm a wee bit confused but then again....that's just me.

    OK, I'm gonna take a poke at it....

    Code:
    If Nz(DLookUp("[SubFormTableID]", "[SubFormTable]", "[SubTableID]=" &  _
                        Me.myComboBoxName.Column(0)), 0) > 0 Then
    Code:
    Forms("youMainFormName")("yourSubFormControlName").Form.RecordSource  = _
               "SELECT * FROM mySubFormTableName WHERE SubFormTableID=" & _
               Me.myComboBoxName.Column(0) & ";"
    Else
        Dim Ctrl1 As Control, Ctrl2 As Control
       Ctrl1 = Forms("youMainFormName")("yourSubFormName").Form.TheFirstControlNameInSubForm
       Ctrl2 = Forms("youMainFormName")("yourSubFormName").Form.TheSecondControlNameInSubForm
    
      Ctrl1 = Me.myComboBoxName.Column(0)
      Ctrl2 = Me.myComboBoxName.Column(1)
    End If
    


    (not tested)

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


  3. #3
    Join Date
    Oct 2003
    Posts
    233
    thnks man , thats great didnt try yet, but i can get there from here, as far as the filter, if the pk from the cbo isnt found, then i push the vals starting a new rec

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    then i push the vals starting a new rec
    which is what the Else portion of the If statement does.

    .
    Environment:
    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
  •