Solved

combobox find specified record from the list?

Posted on 2006-10-28
12
247 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 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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