Solved

Form and Sub Form Default Values

Posted on 2009-05-04
5
172 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

815 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

10 Experts available now in Live!

Get 1:1 Help Now