Solved

Form and Sub Form Default Values

Posted on 2009-05-04
5
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

687 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