Link to home
Start Free TrialLog in
Avatar of ongjocelyn
ongjocelyn

asked on

Form and Sub Form Default Values

I created a main form with a sub form.  In the main form, I have two combo boxes i.e. combo1 and combo0.  combo1 value controls the drop down list in combo0.  So far what I have done works perfectly fine as what is selected in combo0 displays the correct field information in the main form and the sub form.  The storeid links sub form to the main form.  

In combo1, I set "grocery" as the default storetype and in combo0, I have set 127 as the default storeid, so that when I open the main form, 127 storeid is alredy preselected.  However, on open, the sub form does not display the record of storeid #127.  It displays storeid #1 everytime the main form is opened.  How to make them sync? I want to be able to see the record of storeid #127 display on open.

Thanks in advance.
Avatar of tbsgadi
tbsgadi
Flag of Israel image

Hi ongjocelyn,

Have you set the link parent/child fields for the subform?

Gary
ASKER CERTIFIED SOLUTION
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ongjocelyn
ongjocelyn

ASKER

Hi Gary, I did set the link parent/child fields for the subform.

Hi Mike, I will try that and let you know whether it works.
The combo in the main form shows StoreID=127 but do you have any other information on the main form to show that you're on StoreID=127?
If you haven't got the combo afterupdate You need to have code like this
Private Sub Combo0_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
 
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![Combo0], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Open in new window