Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2012
    Posts
    18

    Unanswered: Having Issues with Looping

    I have two list boxes on my form ErrorCodeDescription and ErrorCodesandCorrections. In my two list boxes I am giving the user the option to choose as many choices as they deem that is necessary. I am having issues with how my information is showing up on the Report that's generated from what the user inputs on the form. My issue is that I am using a loop and for ErrorCodeDescription its working correctly however for ErrorCodesandCorrections its importing incorrectly. Can anyone give me some help on how to fix this matter? I have attached a copy of the out put as well and the code

    Dim oItem As Variant
    Dim oItem1 As Variant
    Dim sTemp As String
    Dim sTemp1 As String
    Dim iCount As Integer
    Dim iCount1 As Integer

    iCount = 0
    If Me!ErrorCodeDescriptionList88.ItemsSelected.Count <> 0 Then
    For Each oItem In Me!ErrorCodeDescriptionList88.ItemsSelected
    If iCount = 0 Then
    sTemp = sTemp & Me!ErrorCodeDescriptionList88.ItemData(oItem)
    iCount = iCount + 1
    Else
    sTemp = sTemp & ";" & Me!ErrorCodeDescriptionList88.ItemData(oItem)
    iCount = iCount + 1
    End If
    Next oItem
    Else
    MsgBox "Nothing was selected from the list", vbInformation
    Exit Sub 'Nothing was selected
    End If

    iCount1 = 0
    If Me!ErrorCodesandCorrectionsList.ItemsSelected.Coun t <> 0 Then
    For Each oItem1 In Me!ErrorCodesandCorrectionsList.ItemsSelected
    If iCount1 = 0 Then
    sTemp1 = sTemp & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
    iCount1 = iCount1 + 1
    Else
    sTemp1 = sTemp & ";" & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
    iCount1 = iCount1 + 1
    End If
    Next oItem1
    Else
    MsgBox "Nothing was selected from the list", vbInformation
    Exit Sub 'Nothing was selected
    End If

    Me!ErrorCodeDescriptionList88.Value = sTemp
    Me!ErrorCodesandCorrectionsList.Value = sTemp1
    Attached Files Attached Files

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I guess you decided to post here instead?

    This help?

    For Each oItem1
    sTemp1 = sTemp & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
    Paul

  3. #3
    Join Date
    Jul 2012
    Posts
    18

    Having Issues with Looping

    pbaldy

    I use both site sometimes to post it just depends on what type of day it is so far. And Thanks for the information AGAIN.....

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help!
    Paul

  5. #5
    Join Date
    Jul 2012
    Posts
    18

    Having Issues with Looping

    Ok Paul remember I am a Newbie so after ELSE I am suppose to add

    For Each oItem1
    sTemp1 = sTemp & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
    and then remove
    iCount1 = iCount1 + 1
    or just add
    sTemp1 = sTemp & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
    and delete everything else?
    I am having a blonde moment.....

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Did you note the items in red? You start with one variable and then use the other.
    Paul

  7. #7
    Join Date
    Jul 2012
    Posts
    18

    Having Issues with Looping

    Paul,

    Again Thank You so much for your assistance on this matter and also Thank You on your book suggestion as well.....I am quite sure I will need your assistance again very soon. The first round is on me

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help!
    Paul

Posting Permissions

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