Originally Posted by
gmayor
It is probably easier to use select case for the choices and as you have not explained what the abbreviations represent then the following is probably close.
Thanks for that gmayor. Case will work perfectly fine however I feel that there is still a lot of manual editing when new companies / contacts become available or having to remove contacts etc.
I'm trying to do a loop through a predefined list of contacts when a selected company is selected (also predefined)
For this part of my coding I am essentially showing a list of contacts from whichever company has been selected in my form. I was looking into a loop while or loop until style of shortening the code but it also may not be possible. The idea was something along the lines of:
Dim i As Integer, k As Integer
Dim s As String
k = 11 ' this determines the exit condition
For i = 1 To 10
If k = i Then Exit For
s = IIf(s = "", i, s & " " & i) ' construct the string
Next
Me.ListBox3.Clear
Me.ListBox3.AddItem ALBF & i & " " & ALBL & i ' add in listbox
s = ""
or
Dim LCounter As Integer
For LCounter = 1 To 10 Step 1
With ListBox3
.AddItem Text:=ALBF & LCounter
End With
Next LCounter
Me.ListBox3.Clear
Me.ListBox3.AddItem TypeText.Text(ALB) & LCounter & TypeText.F & " " & "ALB" & LCounter & "L"
Next LCounter
So it would go through ALBFx, which would be ALBF1, then ALBF2 and so on, likewise with ALBL1 ...
I'm hoping this helps when the explaining I apologies in advance if I'm not explaining it to well.