LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Dynamic Text boxes in UserForm

I'm a VBA rookie using Excel 2002. I set up a simple userform with a
ComboBox populated from an Outlook 2002 contacts folder. It's working
fine. When the user selects a name from the ComboBox, the macro fills
some cells with the contact's Name, Address,etc. I'd like to upgrade
my userform to have dynamic text boxes. When the user selects a
contact, but has yet to click OK, I'd like the text boxes to update
with that contact's info.

I'm doing pretty well with the Outlook interface (thanks to Dick
Kusleika), so I can get the data I want from Outlook. I just can't
figure out how to do the text boxes. I'm attaching the code I have so
far. It all works. Any help would be greatly appreciated.
_______

Option Explicit

Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim Fldr As Outlook.MAPIFolder
Dim olCi As Outlook.ContactItem
Dim olItems As Outlook.Items
Dim custFldr As Outlook.MAPIFolder

Private Sub UserForm_Initialize()

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.Folders(1)
Set custFldr = Fldr.Folders("Customers")
Set olItems = custFldr.Items
olItems.Sort "[LastName]", False

For Each olCi In olItems
Me.ComboBox1.AddItem olCi.LastName
Next olCi

End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing

End Sub

Private Sub btnOK_Click()

If ComboBox1.ListIndex < 0 Then
Beep
Else



For Each olCi In olItems
If olCi.LastName = Me.ComboBox1.Value Then
[LName] = olCi.LastName
[Fname] = olCi.FirstName
[Sname] = olCi.Spouse
[AddrStreet] = olCi.MailingAddressStreet
[AddrCity] = olCi.MailingAddressCity
[AddrZip] = olCi.MailingAddressPostalCode
[Phone] = olCi.HomeTelephoneNumber

Exit For
End If
Next olCi

Unload Me

End If

End Sub

Private Sub btnCancel_Click()

Unload Me

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
Linked/dynamic Chart titles, text boxes etc... e18 Excel Discussion (Misc queries) 3 March 17th 06 09:45 AM
buttons and boxes in userform Larry Sartoris Excel Discussion (Misc queries) 3 January 20th 06 04:39 PM
Populate Userform text boxes in VBA with VLookup data from #2 worksheet Laz[_2_] Excel Programming 4 October 8th 03 02:15 AM
userform text boxes Jo[_4_] Excel Programming 4 September 23rd 03 03:38 AM


All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"