Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Alpine Califormia


    I created a table called the Family_Hours (look up table for a combo box)
    this is based on the type of family and how many chidren they have and if
    dad is at home then that determines how many hours they are responsible for
    per week and month.
    The table has three fields one is called TypeOfPariticpant, Month and Weekly

    2 parent family = Weekly_hrs 40 Hours = Month 173 Hours
    single parent child over 6 years = Weekly_hrs 30 hours = Month 130 Hours
    sigle parent child under 6 years = Weekly_hrs 20 hours = Month 87 Hours
    child under 1 year = Weekly_hrs 0 hours = Month 0 Hours

    the users wants to choose what kind of family it is then have the hours
    automatically pop up in the drop down. I hope that makes sense??
    The part with the family is called TypeofParticipant the lower numbers are
    WeeklyHours and the Higher numbers are Montly totals

    and in the Event View under AfterUpdate here is the code I used

    Combo1.RowSource = "SELECT FamilyHrID, TypeOfParticipant, WeeklyHours,
    MonthlyHours FROM FamilyHours_tbl"
    Combo1.ColumnCount = 4
    Combo1.ColumnWidths = 0cm;2,503cm;0cm;0cm (sorry: in centimetres here!)
    Combo1.BoundColumn = 1
    Combo1.LimitToList = True

    Combo2.RowSource = "SELECT FamilyHrID, WeeklyHours FROM FamilyHours_tbl"
    Combo2.ColumnCount = 2
    Combo2.ColumnWidths = 0cm;2,503cm
    Combo2.BoundColumn = 2
    Combo2.LimitToList = True

    Combo3.RowSource = "SELECT FamilyHrID, MonthlyHours FROM FamilyHours_tbl"
    Combo3.ColumnCount = 2
    Combo3.ColumnWidths = 0cm;2,503cm
    Combo3.BoundColumn = 2
    Combo3.LimitToList = True

    Private Sub TypeOfParticipant_AfterUpdate()
    Me.Weekly = Me.TypeOfParticipant.Column(2)
    Me.Month = Me.TypeOfParticipant.Column(3)
    End Sub
    I need to hard code this into the afterupdate of the combo box instead of
    using a lookup table and then coding it. and I was wondering how would I do
    this. The Fields will never change, they will always remain the same there
    wont be any change to TypeofParticipants, will always be the same thing. Can
    someone show me how I can hard code this in and just use the Combo box
    instead, please? Thank you

  2. #2
    Join Date
    Dec 2004
    Madison, WI
    To hardcode values in combobox:

    1. Select the combobox and view it's properties.
    2. Change the Row Source Type to: Value List.
    3. For Row Source, enter your values: ie. "James";"John";"Pete";"Joe"

    Make sure to setup your column count correctly. You can have it show one value while entering another but typically you use 1 column when doing it like that above.

    Note: the same method can be done for listboxes.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Feb 2004
    Alpine Califormia
    Well there's three combo boxes one is the TypeofParticipant and the other two is the WeeklyHrs and the Month. What I wanted to do is when the user chooses from the typeofparticipant then the Month and Week would populate automatically according to what was chosen in the typeofparticipant drop down

  4. #4
    Join Date
    Dec 2004
    Madison, WI
    You'll need to relate the typeofparticipant with the Month/Week in a table somehow.

    Then you can either have those fields as part of the recordsource for the combobox or use the dlookup command. You would populate the other fields in the AfterUpdate event of the combobox.

    ex 1:
    me!MyOtherMonthField = me.MyComboboxName.Column(2)
    me!MyOtherMonthField = dlookup("[MonthValue]","MytypeofparticipantTable","[typeofparticipant] = '" & Forms!MyFormName!MyComboboxName & "'")
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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