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
Solved

Open Forms with no data showing

Posted on 2004-03-29
3
153 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article will show, step by step, how to integrate R code into a R Sweave document
This is about my first experience with programming Arduino.

791 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