• column from 1 column box filling another (97 sr2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » column from 1 column box filling another (97 sr2)

    Author
    Topic
    #377519

    I have been trying in vain to have the data in column(1) of a combo box fill in another combo box(or text box for that matter) on a form. I have a combo box with 2 columns – 1 for town and the second for county. Since there can be more than 1 town with the same name in the state I have to attach the county to the source record as well as town.. I would like the county field to be the result of the choice in the combo, since the combo table has each town and county in its two fields. I hope someone can follow this. I am going crazy trying so many different ideas. I would be willing to do it as an update query that is run with the push of a button if need be, but I can’t get to the data in the second column. HELP!!!!!!!

    Viewing 0 reply threads
    Author
    Replies
    • #621946

      To place the county in a textbox on the form, on an Event (I used OnExit for an example) of the Town combobox, place the following code:

      Private Sub Town_Exit(Cancel As Integer)
      
          If Not IsNull(Me![Town]) Then
              Me![County] = Me![Town].Column(1)
          Else
              MsgBox ("Please select a Town from the dropdown box")
          End If
          
      End Sub

      The example uses Town as the name of the combobox and County as the name of the textbox. You will need to change them to your own names. HTH

      • #622004

        Actually, I think the AfterUpdate event of the combobox would be a better choice than OnExit. AfterUpdate will occur even if the combobox doesn’t lose the focus.

    Viewing 0 reply threads
    Reply To: column from 1 column box filling another (97 sr2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: