473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Subform doesn't show any records

Hi,

I'm having an issue with MS Access 2010 which drives me crazy.
I do have a form with some subforms. The subforms are not linked to the main form, but their recordsource queries on some fields on the mainform.
So far so good. If I change the values of the fields on the mainform the subforms are showing the correct records.

However when I reset the values on the mainform with some VBA code the issue begins.

Let's say one of my subforms has the following sourceobject: Me.[Subformulier].SourceObject = "Form A"


When I reset the mainform I use below code:

Expand|Select|Wrap|Line Numbers
  1. Me.[Subformulier].SourceObject = ""
  2.  
  3. ..
  4. execute some code
  5.  
  6. ..
  7.  
  8. Me.[Subformulier].SourceObject = "Form A"

However my Subform isn't returning any records.
The funny thing is however when I open the subform it is showing exactly the records I was looking for...

Can anyone help me with this?
Jun 20 '16 #1
2 1218
OK, looks like I've found the answer elsewhere. It appeared that my mainform was bound to a query were it shouldn't have been.
Removing this bound query did the trick.
Thought I knew MS Access a bit, but appearantly there is still much to learn.
Jun 21 '16 #2
jforbes
1,107 Expert 1GB
By setting the SourceObject of the SubForm, you are tell MSAccess what Form to stuff into that SubForm container. If you plan to always use the same SubForm, you might find things work better by leaving the SourceObject alone and instead update the SubForm Filter to hide and show the records you are interested in.

This is an example of using this approach.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSourceDrawing1_AfterUpdate()
  2.  
  3.     Dim sDrawingName As String
  4.  
  5.     sDrawingName = Nz(Me.cboSourceDrawing1.Value, "")
  6.  
  7.     If Len(sDrawingName) > 0 Then
  8.         Me.Source1Sub.Form.Filter = "DocNumber='" & sDrawingName & "' AND DocType='Drawing'"
  9.         Me.Source1Sub.Form.FilterOn = True
  10.     Else
  11.         Me.Source1Sub.Form.Filter = "1=2"
  12.     End If
  13.  
  14. End Sub
The SubForm has had it's LinkMasterFields and LinkChildFields cleared out as that is often not needed for this approach. On the Form, when the user selects a different drawing in the cboSourceDrawing1 ComboBox, the SubForm is Filtered to only show records associated with that Drawing. If they clear out the ComboBox, the Filter is set to a permanent False condition, which will hide all the records and show nothing in the SubForm.

This is just an option, you can take it or leave it.
Jun 21 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Daniel | last post by:
when i set the BackgroundImage property in the designer the image still doesnt show in the background of the textbox any other property must be set?
0
by: Daniel | last post by:
how to make sure a xsl document has valid xsl syntax? i tried loading it into an xml document but that doesnt show syntax errors inside attributes such as "foo/bar" vs "bar\foo"
3
by: Mark | last post by:
When a main form goes to a different record, how do you detect that the subform has no records? Thanks! Mark
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
1
by: PAUL MITCHELL | last post by:
Hello, bit of strange one this, I have a VB .net application that has Sub Main() as its startup procedure, this then creates and shows a form. Up till now when I pressed F5 the form would duly...
4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that...
0
by: hwDevelop | last post by:
I have a toolstrip with several buttons on it, but when i changed the images, most of them doesnt show on runtime. I tried several different formats .bmp, .png, .ico for these buttons without any...
1
by: Shona Rennie | last post by:
I have the following in a form: - Main Form which stores EE details - 1st subform - a continuous form with a combo box which allows either selection of an existing contract or option to open...
2
Daniel B
by: Daniel B | last post by:
I have a subform that displays records of information. When a new record is created and saved, the record will appear in the tables, but not in the subform. It seems that when I fill in...
1
by: yukiLeong | last post by:
I facing a problem when doing my final assignment. I really no idea for it? Can help me to solve the problem? In audit fees main form contained the subform name table workload. I wish to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.