Solved

combobox find specified record from the list?

Posted on 2006-10-28
12
243 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

919 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

18 Experts available now in Live!

Get 1:1 Help Now