Solved

Open Forms with no data showing

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

11 Experts available now in Live!

Get 1:1 Help Now