Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

combobox find specified record from the list?

Posted on 2006-10-28
12
Medium Priority
?
251 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 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

916 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