Loop & get component property

PaulGer

Registered User.
Local time
Today, 09:07
Joined
Oct 6, 2003
Messages
10
Hi, I am trying this code;
Code:
    Dim i As Integer
    Dim usrMsg, vname, phone As String
    For i = 1 To 3
        vname = Me.comboContact & i.Column(1)
        phone = DLookup("[Phone]", "tblContact", "[Name]=" & SQLstring(vname))
        usrMsg = usrMsg & vname & ": " & phone & vbNewLine
    Next i
    MsgBox usrMsg, vbInformation, "Contacts"
To build up a string to show in a MsgBox for the user. Basically what I want the loop to do is;

name = Me.comboContact1.Column(1)
...
name = Me.comboContact2.Column(1)
...
name = Me.comboContact3.Column(1)

Hope you guys can help me out! :)

Cheers
 
This?

name = Me.comboContact1.Column(1)
...
name = name & Me.comboContact2.Column(1)
...
name = name & Me.comboContact3.Column(1)
 
No, I'll try explain a bit more, basically the MsgBox should look like this;

Fred: 31994
Bob: 59161
Steve: 75016

tblContact has these fields;
[Name]
[Phone]

There are 3 combobox's, named comboContact1, comboContact2, comboContact3, in each combobox there is a Name from tblContacts [Name] field

Hope that makes it a bit clearer :)
 
Nevermind, got it :D

Just replaced
Code:
vname = Me.comboContact & i.Column(1)
With a CASE statement.
 

Users who are viewing this thread

Back
Top Bottom