Combo box selection

Harley

Registered User.
Local time
Today, 11:28
Joined
Dec 8, 2005
Messages
54
I have a form with 4 text boxes that are populated from a query with an unbound cbo box to make the choice from. There are two fields that show on the dropdown, "Customer" and "New Product Name". I created it all with wizards. Most of the Customers have only one product name but some have several. If I choose a customer that has several products, it always selects the customer with the first product it finds. How can I get it to select the Customer by product? I have looked and seen what looked like what I needed on this forum, but I couldn't make it work. I am not good a VB. Thanks in advance for any help that you can give.
 
Post ALL of the AfterUpdate event code of the ComboBox from Private...to...End Sub and we'll show you how to change it so it will do what you wish.
 
CBO box

Okay, Much thanks.

Private Sub Combo10_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Customer] = '" & Me![Combo10] & "'"
Me.Bookmark = rs.Bookmark
End Sub

That's it!
 
rs.FindFirst "[New Product Name] = '" & Me!Combo10.Column(1) & "'"
 
I replaced the re.Findirst line with the one that you suggested and it chose the first "New Product Name", which is not what I wanted. I am not sure what you intended for me to do, but I made a stab in the dark, and it worked. I will paste it here for others and also for you to check to make sure that I am not asking for trouble! ;-) I appreciate your help very much.
Harley
Private Sub Combo10_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Customer] = '" & Me![Combo10] & "'"
rs.FindNext "[New Product Name] = '" & Me!Combo10.Column(1) & "'"
Me.Bookmark = rs.Bookmark
End Sub
 
Do you have any suggestions as to where/how that I may study or at least have a reference to writing code?
 
I own many pounds of Access books (I think they charge by the weight) and they were invaluable in getting started. There is a pretty good reading list here on this site. I also enjoy reading and understanding other people's sample code. Have you looked behind the NorthWind sample db that comes with Access. The internet is just loaded with sample db's that demonstrate various methods of coding. Good luck and enjoy the learning process.
 
I don't have a copy of the Northwind sample db. I am on the company network. Do you know if that is available somewhere, free is good! :-)
Thanks again
 
I don't have a copy of the Northwind sample db. I am on the company network. Do you know if that is available somewhere, free is good! :-)
Thanks again
 
Are you sure? It is located under the Help>Sample Databases... It comes free with Access and may not have been installed originally but could certainly be added on a reinstall.
 

Users who are viewing this thread

Back
Top Bottom