I'd like to change a text box in my form to a combo box, which I can do. This field is the primary key. How do I get the rest of the fields to update to the correct records when a value is selected in the combo box?
Hey Doug,
The form is based off of a query. What I'd like to have happen, is a user clicks on a menu Item in the combo box, then the rest of the fields automatically update. (kind of a way to search through the records). I don't think it's bound.
If your other columns are bound, you could use the value of the combo box to determine the value to use in a .seek method against the primarykey of the table.
look up seek in help to find out the details.
The other option is to attach a query to the afterupdate event of the combo box using recordsets, and fill in the other (unbound) fields on the form by referencing the column names returned by the query...
for instance...
Dim db1 As Database, rst1 As Recordset, sql1 As String
Set db1 = CurrentDb
sql1 = "select * from your_table where table_column= '" & Me!Combobox & "';"
Set rst1 = db1.OpenRecordset(sql1)
rst1.Requery
If rst1.RecordCount <> 0 Then
Me!field1 = rst1!table_field1
Me!field2 = rst1!table_field2
end if
(the disadvantage of this is that the fields are unbound and you are getting a query result set as opposed to the first option where you would get an active dataset where you could move forward and backward using navigation buttons)
I looked up .seek in the help menu and couldn't find anything. I do know now that they are bound controls. Anyone know about this .seek function that Nebuchednezzar was talking about?
Don't lookup ".seek", look up "seek" There are 4 different entries in the help for this. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.