Solved

Form and Sub Form Default Values

Posted on 2009-05-04
5
170 Views
Last Modified: 2013-11-28
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.
0
Comment
Question by:ongjocelyn
  • 3
5 Comments
 
LVL 46

Expert Comment

by:tbsgadi
Comment Utility
Hi ongjocelyn,

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

Gary
0
 
LVL 27

Accepted Solution

by:
MikeToole earned 500 total points
Comment Utility
Presumably the combo boxes are unbound and you're using them to allow the user to select the storetype/store? If that's so there must be some code in the AfterUpdate event of combo0 to make the selection the current record in the main form. The after update event isn't triggered when the default is set on form open. You can fix that by calling the AfterUpdate event routine from the formload event.
0
 

Author Comment

by:ongjocelyn
Comment Utility
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.
0
 
LVL 46

Expert Comment

by:tbsgadi
Comment Utility
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?
0
 
LVL 46

Expert Comment

by:tbsgadi
Comment Utility
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

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now