Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo box question (2003/All)

    I have a form that records reading ages (RA) of children and the results are for a particular date (although the results may not be entered immediately).

    To overcome a problem where the RA is compared to the chronological age (CA) of the student I want to use a combo box with the range 0-12 for the number of months that have passed since the test. The combo box (cmbRA_Diff) would apply a 'correction factor' to the difference between the RA and the CA. This difference uses some code provided by Hans. The age display on the form of the RA and the difference is in this format: <font color=blue>7.11 </font color=blue> being 7 years and 11 months and <font color=blue>-0.4</font color=blue> being an RA just four months behind chronological age.

    My question is relating to 'capture' of the data for a particular date. I am unsure of how to use the combo box selection in the code.

    My adaption of Hans' original code for one of the three years of RA capture is below.

    <pre>Private Sub CalcDiff2()
    Dim intPos1 As Integer
    Dim intYr1 As Integer
    Dim intMn1 As Integer
    Dim intAg1 As Integer
    Dim intPos2 As Integer
    Dim intYr2 As Integer
    Dim intMn2 As Integer
    Dim intAg2 As Integer
    Dim intDif As Integer
    Dim strRes As String

    If Not IsNull(Me.txtChronAge) And Not IsNull(Me.txtY2RA) Then
    If txtY2RA.Value = "" Then Exit Sub
    intPos1 = InStr(Me.txtChronAge, ".")
    intYr1 = CInt(Left(Me.txtChronAge, intPos1 - 1))
    intMn1 = CInt(Mid(Me.txtChronAge, intPos1 + 1))
    intAg1 = 12 * intYr1 + intMn1
    intPos2 = InStr(Me.txtY2RA, ".")
    intYr2 = CInt(Left(Me.txtY2RA, intPos2 - 1))
    intMn2 = CInt(Mid(Me.txtY2RA, intPos2 + 1))
    intAg2 = 12 * intYr2 + intMn2
    intDif = intAg2 - intAg1
    If intDif < 0 Then
    strRes = "-"
    intDif = -intDif
    End If
    strRes = strRes & (intDif 12) & "." & (intDif Mod 12)
    Me.txtY2RALev = strRes
    End If

    Exit Sub

    End Sub</pre>



    Any suggestions on how to achieve the application of a correction factor would be helpful.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo box question (2003/All)

    The line

    <code> intDif = intAg2 - intAg1</code>


    calculates the difference in months between RA and CA. Since your combo box will also be in months, you can subtract its value from intDif at this point:

    <code> intDif = intAg2 - intAg1
    If Not IsNull(Me.cmbRA_Diff) Then
    intDif = intDif - Me.cmbRA_Diff
    End If
    If intDif < 0 Then
    ...
    ...</code>

    or should it be added - getting confused now!

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo box question (2003/All)

    Thanks Hans - your last line about whether it should be added is correct.

    By example, if the testing was done in March and the Reading Age was 11.5 and the difference between Chronological Age and RA was 0.2, then for the month of December a Correction Factor of 9 would be added to allow for the nine months that have passed since the testing. The true difference would be 0.11 and that is exactly what your code shows (when I changed it to add the difference).

    You have been a great help again.

Posting Permissions

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