Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Form and Sub Form Default Values

Posted on 2009-05-04
5
Medium Priority
?
182 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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