Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advise on list box or listview or maybe something else

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
Have a project..
Lets say it is a address book
The ultimate goal is to display the clients in the address book with there First name & Last name
the user can click on the name and then push a button which will then display further details such as phone number and address.
All the data is coming from an Access database--> this part is fine
Where we are stuck is the displaying of the name..
What to use a list box a listview or something else?
Anyone out there worked on soemthing similar or have some suggestions.
And if possible provide some code
 
just to add.. Also the user can run a search by first name or last name. They do this by entering the name in a text box
 
I think a listview control would be your best way to address this although a flexigrid control will also work well

PK Odendaal
pko@mweb.co.za

 
or List all the users in a DBGrid and with dubbelclick on Row selected User name giving another Form with the related informations
Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
HI

I think you really need to read up on parameter queries. IN this way you can pass the forename/surname entered to the query and then display any records matched.

The same approach applies to a listview/treeview. When the user selects and name - that selection can be passed to the the paramater query and matching records returned.

Just another thought - if this really is to be an address book, most orgainisations should be running an email system that will allow the use of a specific address book and you could use (Outlook for example) VBA to write a front end to allow your users to link to that Outlook address book.

Kate
 
hands down best way is to mult-column combobox it......
on_click it does its thing.
if you need help email me with entire detail and sample format u want in combobox.

drat@mediaone.net
 
I always liked in Access where you could display them in a list box and then you could select a line. You could then run a search based on any data in that line.
Does VB have anythign similar or am 'I dreaming'
 
here's a random sample I pulled out of an Excel ComboBox on click sub in VBA......it's got all kinds of junk you don't need also.....hehehehehehehe



Private Sub ComboBox2_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False

Sheets("Sheet2").Select

ActiveSheet.Shapes("Text Box 60").Visible = False
ActiveSheet.Shapes("ComboBox5").Visible = False
ComboBox5.Enabled = False

ActiveSheet.Shapes("Text Box 4").Visible = True
ActiveSheet.Shapes("ComboBox1").Visible = True
ComboBox1.Enabled = True

selrepRow = ComboBox2.Value
If selrepRow = "Assign a B.U.M." Then
GoTo endsaverep
Else
End If

Sheets("Sheet2").Select
rfqnumber = [Sheet2!C5].Value
If IsEmpty(rfqnumber) Or rfqnumber = "" Or rfqnumber = " " Then
GoTo endsaverep
Else
End If

Sheets("Sheet1").Select
[Sheet1!B1].Select
Do Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(1, 0).Select
Loop
lastrow = ActiveCell.Row - 1

[Sheet1!B1].Select
If lastrow > 65000 Then
GoTo endsaverep
Else
End If
Do Until ActiveCell.Value = rfqnumber
ActiveCell.Offset(1, 0).Select
Loop
existingrep = ActiveCell.Offset(0, 61).Value
If IsEmpty(existingrep) Or existingrep = "" Or existingrep = " " Then

msg = "Do you want to PERMANENTLY Assign " & selrepRow & " to " & "RFQ# " & rfqnumber & " now ?"
Ans = MsgBox(msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
GoTo saverep

Case vbNo
Cancel = True
GoTo endsaverep

Case vbCancel
Cancel = True
GoTo endsaverep

End Select


Else
End If

msg = " " & existingrep & " is currently assigned to RFQ# " & rfqnumber & " now ?" & vbCrLf & vbCrLf & "Do you want to Re-Assign " & selrepRow & " to " & "RFQ# " & rfqnumber & " now ?"
Ans = MsgBox(msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
GoTo saverep

Case vbNo
Cancel = True
GoTo endsaverep

Case vbCancel
Cancel = True
GoTo endsaverep

End Select



saverep:

Sheets("Sheet1").Select
[Sheet1!B1].Select
Do Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(1, 0).Select
Loop
lastrow = ActiveCell.Row - 1

[Sheet1!B1].Select
If lastrow > 65000 Then
GoTo endsaverep
Else
End If

Do Until ActiveCell.Value = rfqnumber
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell.Offset(0, 61).Value = selrepRow

Sheets("Sheet2").Select
[F17].Select
ActiveCell.Value = selrepRow
[C5].Select
Application.DisplayAlerts = False
ActiveWorkbook.Save

endsaverep:

Sheets("Sheet2").Select
[Sheet2!G2].Value = ""
[C5].Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 

Hello again

my, my - what a lot of code RatMan (and from Excel too...)

Try the following, which reads in the contents of an Access table and then places the records into a listbox. The user can then start to type a name into a text box and the list box will "jump" to the relevant entry. Speed shouldn't be a problem for about 1000 records but after that you may encounter problems. In this example I've put all the relevant information (as one string) into the list box. So when the user finds the name they are looking for they have also found the address etc.
If you want the listbox to just contain the name and the address etc in (for example) text boxes then you will have to get into parameter queries - reply to this if you need extra help.

IMPORTANT - make sure the sorted property of the list box is set to TRUE.


Option Explicit
Dim listline As Integer
Dim match As Boolean

Dim someDB As Database
Dim someRecordSet As Recordset
Dim sPrevText As String

Private Sub Form_Activate()

Set someDB = OpenDatabase("c:\windows\desktop\aDB.mdb")
Set someRecordSet = someDB.TableDefs("aTable").OpenRecordset

Do
List1.AddItem someRecordSet.Fields("surname") & ", " & _
someRecordSet.Fields("forename") & ", " & _
someRecordSet.Fields("phone") & ", " & _
someRecordSet.Fields("add1") & ", " & _
someRecordSet.Fields("add2") & ", " & _
someRecordSet.Fields("town") & ", " & _
someRecordSet.Fields("pcode")
someRecordSet.MoveNext
Loop Until someRecordSet.EOF = True

End Sub


Private Sub Text1_Change()
Dim sText As String
Dim sListText As String


If Len(Text1.Text) = 0 Then 'empty text box
List1.ListIndex = 0 'first item in listbox
List1.ListIndex = -1 'clear selection
Else
sText = UCase(Text1.Text)
If Len(sPrevText) < Len(sText) Then
listline = 0
End If
Do
sListText = UCase(Mid(List1.List(listline), 1, Len(sText)))
(Text1.Text))
If sText = sListText Then
match = True
List1.ListIndex = (listline)
Else
match = False
listline = listline + 1
End If

Loop Until match = True _
Or (listline = List1.ListCount) _
Or (sListText > sText)

If (listline = List1.ListCount) Or (sListText > sText) Then
listline = 0
End If

sPrevText = sText

End If

End Sub


Kate

 
Spent another day looking at examples.
The best one that I've seen is on the microsoft site.
It uses the snapshot and then places it in a list box.
After all your help have decided on a list box to be the best.
The only thing is how to use the snapshot example when i'm using the dataenviroment.
Wil continue looking
 
my my ...it looks real good but why do u want the user to type anything in this point and click world?

users usually make errors
remove them with point and click logic via multi-column dynamic range combobox's

good luck

:)

 
I like the sounds of it. Could quite easily move the user details that are displayed after click from a text box ..
Can you tell me more ratman.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top