Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

combobox find specified record from the list?

Posted on 2006-10-28
12
Medium Priority
?
250 Views
Last Modified: 2008-01-09
hello everybody

i have a combo box in my form with 3 fields on it :pelaths,address,phone
the combo box is in the form "pickups" and the records where is in the list of combo box it take it from the table "pelates"

i want when i type in the combo box the "phone" to display me the field "pelaths" or if doesn't much the phone with field "pelaths" then to dispaly me a message ?
can i do this and how?may a i have sample code please?
thank you.
0
Comment
Question by:GIANNHSB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
12 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 2000 total points
ID: 17826013
Best to add one (or two) new (unbound) field to the form, e.g. named: txtPelaths
Now in the combobox's AfterUpdate event use:

Me.txtPelaths = Me.comboname.column(0)
Me.Refresh

This will show the first field of the combo fields (starts with 0 and not 1 !)
For the other field you can do the same.

Clear ?

Nic;o)
0
 

Author Comment

by:GIANNHSB
ID: 17826044
you mean to add to combo box the first finds the item pelaths and the other finds the phone?

that you mean?
0
 

Author Comment

by:GIANNHSB
ID: 17826046
i mean two combo boxes?
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:GIANNHSB
ID: 17826075
NO you don't understand what i mean...
i say that in the combo box named "pelaths" who has this 3 fields: pelaths,address,phone i want if i type the the third item of the list(phone) to display me the first item, if that two is the same .. that i mean
0
 
LVL 54

Expert Comment

by:nico5038
ID: 17826078
No, a combobox can only have one (unique) value to make it work properly.
The "Bound column" that's specified in the properties under the Datatab will act as the unique column and in general having multiple columns this column is hidden.
When you have the need for pelaths selection showing the address and phone and
the need for a phone showing the pelaths, then two combooboxes will be needed.

Keep in mind that a phone can point to multiple pelaths and thus you would need a trick to get a query showing all pelaths for one phone to make such a combo work.

An alternative will be to use a subform linked to the combo to show the hits for a selection.
This would also imply for two selections two combo's and two subforms.

Personally I just offer my users a datasheet subform and instruct them to use the right-click popup menu. This will allow them to filter and sort the fields as needed and searching by phone will show all hits.
Check my right-click instruction on www.geocities.com/nico5038 to see how that works.

Need more info ?

Nic;o)
0
 

Author Comment

by:GIANNHSB
ID: 17826161
ok tell me something if i put another combo box with 1 item only phone can i much this two combo boxes and if i type into the second combbox the phone to display me the name into the other?
0
 
LVL 54

Expert Comment

by:nico5038
ID: 17826202
You can manipulate the other combo's rowsource by adding a WHERE clause for the phone number.
This is called cascading comboboxes and can be achieved e.g. by this code in the afterupdate event of the first combo:

me.combo2.rowsource = "select pelaths, address from tblX where phone='" & me.combo1 & "'"
me.combo2.requery

Getting the idea ?

Nic;o)
0
 

Author Comment

by:GIANNHSB
ID: 17826246
i'm trying i will try this and i will tell you in few minutes ok?
0
 

Author Comment

by:GIANNHSB
ID: 17826398
i use this but it doesn't work
Private Sub Combo100_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst Me!pelates![THLEFONO1] = Me.PELATHS.Column(0) & " '"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

the thlefono1 is combobox
the pelaths is compo box
0
 
LVL 54

Expert Comment

by:nico5038
ID: 17826568
This code has been placed in the AfterUpdate event of the combo named: Combo100
Looks to me you think it's named PELATHS.

Just click a combo once and check under the Other tab of the properties window the name of the control.
You need to change the rowsource of the second combo (check the name!) like:

me.<name of combo2>.rowsource = "select pelaths, address from tblX where phone='" & me.combo1 & "'"
me.combo2.requery

When still puzzled, try to upload your .mdb to www.ee-stuff.com for this question so we can have a look.

Nic;o)
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question