Results 1 to 6 of 6

dynamic combo box

  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    dynamic combo box

    thought i would share this as i found it very useful. a member here helped me with the first code that populates a combo box based on todays date plus 14 more days which for scheduling dates works great.
    Code:
        Me.cbojune.RowSourceType = "value list"
        Me.cbojune.AddItem Date
        For x = 1 To 14
        Me.cbojune.AddItem Date + x
        Next
    from there i also needed one that would work for scheduling for a week period so this takes the first and uses that concept but instead finds the dates by Mondays.


    Code:
        Dim str As Date
        str = ((Date + (7 - Weekday(Date, 2)) + 1) - 14)
        Me.cboschedulemonday.RowSourceType = "value list"
        Me.cboschedulemonday.AddItem (str)
        For x = 1 To 3
        y = y + 7
        Me.cboschedulemonday.AddItem (str) + y
        Next
    it populates with last Monday, this Monday and the next two Mondays. from there i can populate my end date in the afterupdate. its a simple code but i have found it very handy and thought someone else learning like myself might also.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    6,436
    Nice of you to offer something you found useful. Even better that you were able to learn a technique then adapt it to augment your project. Being able to adapt is key to developing your skill and shows that you can create, not just copy.

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Thank You Micron. From a learners perspective i know a lot of individuals come here just to copy something and move on but i wish there was more of these simpler challenges posted here as that's how i learn. i enjoy the challenge but sometimes we need to learn it in smaller chunks. if i don't understand it how am i going to fix it when it breaks?

  4. #4
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    i have found an error that it is not showing just the original 3 dates i set up but is actually gaining a week each week. if anyone has a solution please post. until then i'll keep working on it

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    8,477
    not showing just the original 3 dates i set up but is actually gaining a week each week
    Don't really understand what you mean here.

    I don't know how you are filling the combo boxes....I used 2 buttons. I did find that the value lists kept growing every time I clicked the buttons.

    I modified the code to clear the value list:
    Code:
        Dim str As Date
        str = ((Date + (7 - Weekday(Date, 2)) + 1) - 14)
        Me.cboschedulemonday.RowSourceType = "value list"
        Me.cboschedulemonday.RowSource = ""
        Me.cboschedulemonday.AddItem (str)
        For x = 1 To 3
            y = y + 7
            Me.cboschedulemonday.AddItem (str) + y
        Next
    Code:
        Me.cbojune.RowSourceType = "value list"
        Me.cbojune.RowSource = ""
        Me.cbojune.AddItem Date
        For x = 1 To 14
            Me.cbojune.AddItem Date + x
        Next
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  6. #6
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    thanks Steve, that's what i was trying to get across. i'll try your fix.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. combo box with dynamic dates?
    By vicsaccess in forum Forms
    Replies: 2
    Last Post: 12-29-2015, 08:13 PM
  2. Dynamic Combo choices for years
    By ptenhet in forum Forms
    Replies: 2
    Last Post: 02-17-2015, 06:08 PM
  3. dynamic combo boxes
    By brad in forum Forms
    Replies: 1
    Last Post: 04-15-2013, 01:07 PM
  4. Dynamic combo box
    By Accessuser67 in forum Forms
    Replies: 6
    Last Post: 01-10-2013, 03:23 PM
  5. Dynamic Cascading Combo Box
    By Userdd in forum Forms
    Replies: 5
    Last Post: 07-24-2011, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums