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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form + Subform & Requeries

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
US
I have a form and a subform linked directly to tables. I have the name of the record as a combo-drop-down box. I want the user to be able to select somethign from the list - and i want the records to automatically populate based on what I select. Keep in mind I have a form and subform.
 
In the AfterUpdate event for the combobox, use the following:

Dim rst as Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "Name = '" & Me.Combo0 & "'"
Me.Bookmark = rst.Bookmark

When the parent form updates, the subform will update with it.
 
cool - how do i set up the combo drop-down box? i basically am making an "edit records" page and i want the user to be able to select an already created record. i need some help i am pretty clueless with the requery/filter type of stuff.
thanks!

also - what in your code do i substitute for my own stuff and what stays the same?
 
let me revise my question:

rst.FindFirst "Name = '" & combo0 & "'"

is giving me problems
 
If you go through the combobox wizard and select the field from the table, that's all you need. If you only want users accessing existing records, set the combobox's LimitToList property to Yes. I'm assuming that the combobox will contain a string. If it's a number, take ' out of FindFirst. All you need to change in the code above is FindFirst.

rst.FindFirst &quot;<fieldname> = '&quot; & <combobox name> & &quot;'&quot;

If you need to requery the combobox:
<combobox name>.Requery
 
ok i dont' have a wizard to set the combo box up like - what settings should I use? nothing seems to work at all! gah.
 
Oh. For the combobox, check the Control Source property. I'm assuming that the form has Record Source set to the table. In the combobox's Control Source, choose the field that it's supposed to relate to. If Control Source is set to the field, you don't need to do anything else with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top