Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35
  1. #16
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

    I tend to write maintainable code rather than something to get the job done unless execution speed is a consideration. I may have to change it in a few years and forget what on earth I did. The two pieces of information are available in the RowSource of the ComboBox but the modification factor is not. That means you will need to "hard code" that mod factor so the clearer the process, the easier to change later. I would simply add code to the AfterUpdate event of the ComboBox that shows clearly what you are doing and can easily place the results in whatever control you want.

  2. #17
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    Sorry but I have to be blunt....

    What is the CODE that I need to put in the AfterUpdate event of the Combobox?

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Can you write in words all of the possible permutations and calculations from which we can create the code needed?

  4. #19
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    These should be all the permutations:
    1 Month (30 Days)
    2 Month (60 Days)
    3 Month (90 Days)
    4 Month (120 Days)
    5 Month (150 Days)
    6 Month (180 Days)
    1 Year (365 Days)
    2 Year (730 Days)
    3 Year (1095 Days)
    4 Year (1460 Days)
    5 Year (1825 Days)
    6 Year (2190 Days)
    Initial
    As Needed

    I don't know if the number of days are needed or not, just thought I'd put them on here in case.

    Thanks!

  5. #20
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I was busy yesterday and didn't get back to this until today. The code should be real easy. I'll get to work on it.

  6. #21
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This should get you started. You may need to convert some of the Columns since I don't know the DataType. You will need to also specify the real column number instead of my dummy 99.
    Code:
    Private Sub cboCourseSelection_AfterUpdate()
       Dim CourseFrequency As Double
       Dim CourseTrainingDate As Date
    
       With cboCourseSelection
          CourseFrequency = .Column(99)       '-- Point to the Frequency column of the RowSource
          CourseTrainingDate = .Column(99)    '-- Point to the TrainingDate column of the RowSource
          Select Case .Column(99)             '-- Point to the FrequencyPeriod column of the RowSource
                                              '-- Zero based number so the 2nd column would be (1)
             Case "Month"
                Me.ExpirationDate = DateAdd("m", CourseFrequency, CourseTrainingDate)
             Case "Year"
                Me.ExpirationDate = DateAdd("yyyy", CourseFrequency, CourseTrainingDate)
             Case Else
                '-- do nothing
          End Select
       End With
    End Sub

  7. #22
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    Sorry, I just saw your reply - over a month later...

    Where you have (99) am I supposed to use the table field name?

    Thanks

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A ComboBox has a zero based Column value for selecting the value in that column. Therefore Column(2) would return the value in the 3rd column. It is a number.

  9. #24
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    I can't seem to attach my database so I took a few "screen shots". Attached is a .pdf showing the field I want to "autofill".

    Thanks again!

  10. #25
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    We should establish that FIELDS are in tables and CONTROLS are on forms. CONTROLS can display FIELDS. What is the SQL for the RecordSource of the Form?

  11. #26
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    I'm using the ScheduleCourse Table for the form.....

  12. #27
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So how are you filling in those other controls?

  13. #28
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    I'm not sure which "other controls" you are refering to....

  14. #29
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    FrequencyPeriod and Frequency.

  15. #30
    cin324 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    26
    Those two fields are in another table - I'm guessing I need to create a Query for my form - adding those two fields to it?

    Then they will be controls on the form for use in the calculations?

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate age based on birthday
    By MediaCo in forum Access
    Replies: 10
    Last Post: 10-14-2014, 01:00 PM
  2. Replies: 5
    Last Post: 09-14-2011, 03:41 PM
  3. Replies: 1
    Last Post: 02-06-2011, 06:36 PM
  4. Calculate one field based on another one
    By Douglasrac in forum Forms
    Replies: 7
    Last Post: 11-18-2010, 01:30 PM
  5. Replies: 1
    Last Post: 06-10-2010, 04:36 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
  •  
Other Forums: Microsoft Office Forums