Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box

Status
Not open for further replies.

mrblonde

Technical User
Mar 16, 2001
187
US
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?
 
Is this text/combo box bound to a table

Are you tryning to filter what records are shown?
 
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.

Thanks...
 
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 &quot;.seek&quot;, look up &quot;seek&quot; 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.
 
Yes,
I ended up using the combo wizard after removing the PK field all together. Kind of a cheap solution, but it works...

Thanks...
Mat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top