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: 71
Default QN: Userform Name Search

Hello Everyone,

Can somebody help me with this code that I messed up??? What I am trying to
do is, I created a UserForm that has a TextBox and a SpinButton. I have a
sheet with a database in it that lists a club with Members Names, Addresses,
and Phone No's. Now, the SpinButton portion of the code works, but what I
want to do with the TextBox is, I want to be able to type in a few letters
of the last name, and then it comes up with the name/address and so on info
below where it shows it in the spinbutton. Here is the code that I have
now, can somebody fix the TextBox function for me so that I can type in a
partial name and have it displayed??? NOTE: The code for the TextBox
Change was originally setup for a ListBox, I have a spinbutton instead of a
listbox.

Dim HelpTopic As Integer

Private Sub CancelButton_Click()
Unload Me
End Sub

Private Sub TextBox1_Change()
'the change event runs each time the user
'types into a text box
Dim s As String
Dim i As Integer
s = TextBox1.Text

'Note the use of the ListIndex property of the ListBox
'If the ListIndex is -1 means nothing selected
'If 0 means the first item selected
LabelName.Caption = -1
If TextBox1.Text = "" Then 'nothing typed
Exit Sub
End If
For i = 0 To LabelName.Caption - 1
'use the LIKE operator to compare
'convert both to Uppercase as well so case does not matter
If UCase(LabelName.Caption(i)) Like UCase(s & "*") Then
LabelName.Caption = i
Exit Sub: UpdateForm
End If
Next
End Sub


Private Sub UpdateForm()
HelpTopic = SpinButton1.Value
LabelName.Caption = Sheets("Members").Cells(HelpTopic, 1)
LabelAdd.Caption = Sheets("Members").Cells(HelpTopic, 2)
LabelHome.Caption = Sheets("Members").Cells(HelpTopic, 3)
LabelWork.Caption = Sheets("Members").Cells(HelpTopic, 4)
LabelCell.Caption = Sheets("Members").Cells(HelpTopic, 5)
LabelEmail.Caption = Sheets("Members").Cells(HelpTopic, 6)
Me.Caption = "Sky-Vu Flyers Membership Listing (Pilot " & HelpTopic &
" of " & SpinButton1.Max & ")"
End Sub

Private Sub SpinButton1_Change()
HelpTopic = SpinButton1.Value
UpdateForm
End Sub

Private Sub UserForm_Initialize()
' On Error Resume Next
With SpinButton1
.Max =
Application.WorksheetFunction.CountA(Sheets("Membe rs").Range("A:A"))
.Min = 1
.Value = 1
End With
UpdateForm
End Sub


Thanks in adavance.... Michael


 
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
Functions (search within search result) reply to this please Nick Excel Worksheet Functions 1 February 17th 09 03:57 AM
How do I search excel spreadsheets using multiple search criteria. Kasper Excel Worksheet Functions 4 December 15th 05 12:26 AM
Linking userform to userform in Excel 2003 missmelis01 Excel Programming 2 August 27th 04 08:07 PM
List Search Results in a UserForm BVHis[_14_] Excel Programming 0 June 1st 04 05:57 PM
Search or FIND on a userform. Phillips Excel Programming 2 November 26th 03 09:55 AM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"