Solved

Form and Sub Form Default Values

Posted on 2009-05-04
5
174 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
ID: 24301948
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
ID: 24302991
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
ID: 24317646
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
ID: 24322854
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
ID: 24322875
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

713 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