?
Solved

Open Forms with no data showing

Posted on 2004-03-29
3
Medium Priority
?
158 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 100 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

752 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