Solved

combobox find specified record from the list?

Posted on 2006-10-28
12
242 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
  • 6
  • 4
12 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 500 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now