Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006

    Unanswered: display combo box value at Form load event isue

    Hi community experts,

    May I knw hw can the values of the combo box be displayed at combo box afterupdate event. I want to achieve in such a way whereby at the form load the value displayed at the combo box will be displayed at the textboxs as well.
    Let say S1 happens to be displayed in form load, which mean that values (StudentId, name) corresponding to S1 will be displayed as well.

    Combo box - StudentId (unbounded)
    TextBoxes - StudentId (unbounded)
    name (unbounded)


    Private Sub Combo1_AfterUpdate(Cancel As Integer)
    Dim stud As Variant
    stud = DLookup("IStudentId", "Student", "StudentId = '" & Me.Combo1.Column(0) & "'")
    Me.StudentId.Value = stud
    End Sub.


  2. #2
    Join Date
    Jan 2007
    California, USA
    In the query that is the Row Source for the combo box, you can define multiple columns. Then in the properties for the combo box, under the Format tab, you can specify how many columns are used within this combo box. Then in the AfterUpdate event you can move the second column into the Name text box. The code for that move would look like this:
    Name = Combo1.Columns(1)
    Yes, it is column 1, NOT column 2. The count of columns starts with 0. Look under Columns in the VBA help for more info.

    The AfterUpade event does NOT have a Cancel parameter, the BeforeUpdate event has a Cancel parameter.

Posting Permissions

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