Solved

Open Forms with no data showing

Posted on 2004-03-29
3
155 Views
Last Modified: 2012-05-04
I have a main form with a tab control that contains several inserted subforms.  When I load/open the main form, data appears on the screen.  The main data for the subforms is populated by the main form combo box field which is the primary key for the main form.  

How to I keep data from appearing on the main form and subforms when the form is first opened, without wiping the data out of the table?
0
Comment
Question by:gdunn59
[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 Comments
 
LVL 14

Accepted Solution

by:
JohnK813 earned 25 total points
ID: 10708783
Is it safe to assume you're using Microsoft Access?  If so, in your main forms and each of your subforms, go to your Form Properties -> Data tab -> Record Source, and clear whatever is there.

In your VBA code, whenever you want data to first appear in the main form, enter the line:

Me.RecordSource = (Main form recordsource)

For example:

Me.RecordSource = "tblMain"
or
Me.RecordSource = "SELECT * FROM tblMain"

To update your subforms:
In your main form:

Private Sub Combo1_AfterUpdate()
  Me.SubformName.Requery
End Sub

In the Subform:

Private Sub Form_Current()
  Dim strValue as String
  strValue = Forms!MainForm.Controls!Combo1.Value
  Me.RecordSource = "SELECT * FROM tblMain WHERE SomeField = " & strValue
End Sub

I'm sure you'll have questions on this, so feel free to ask them.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.

734 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