Solved

Access 2013 - Call subform fields

Posted on 2013-05-29
7
890 Views
Last Modified: 2013-07-28
I have a form that I use for collecting information about investigations (frmInvestigation_Detail)

There is a subform in the footer (footer section .visible property = No).  This form is called "sfInvestigation_Matrix"

The Parent/Child link is a field called [Investigation_ID]

Using a graphic with a transparent button, I need to evaluate the code below in the "on-click" event of the transparent button (see attached graphic - "M1" button is the transparent button)

Here is my challenge -

When I click on the button, I get an error message saying "You entered an expression that has an invalid reference to the property Form/Report".

I've verified that the subform and field names are valid and that there is a value in the sub-form field [investigation_id]

What am I missing?
.......................................

Private Sub M1_Click()
Dim intInvID As Integer

On Error GoTo M1_Click_Err

intInvID = Forms!frmInvestigation_Detail!sfInvestigation_Matrix.Form!Investigation_ID



    If (intInvID) > 0 And Not IsNull(Me.Investigation_ID) Then
        DoCmd.OpenForm "sfInvMatrix_M1", acNormal, , [Investigation_ID] = Me.Investigation_ID, , , Me.Investigation_ID
        DoEvents
    ElseIf (intInvID) = 0 Or IsNull(intInvID) And Not IsNull(Me.Investigation_ID) Then
        Me.sfInvestigation_Matrix![Investigation_ID] = Me.Investigation_ID
        DoEvents
        Me.sfInvestigation_Matrix.Requery
        DoEvents
        DoCmd.OpenForm "sfInvMatrix_M1", acNormal, , [Investigation_ID] = Me.Investigation_ID, , , Me.Investigation_ID
        DoEvents
    Else
        MsgBox "Please complete the primary investigation before attempting to complete the investigation matrix", vbOKOnly + vbInformation, "Error: Complete Primary Investigation"
        Me.InvestigatedBy.SetFocus
        DoEvents
        Exit Sub
    End If
   
       
   

M1_Click_Exit:
    Exit Sub

M1_Click_Err:
    MsgBox Error$
    Resume M1_Click_Exit

End Sub
Investigation-Matrix.png
0
Comment
Question by:4GvnNot4Gotn
  • 4
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39205672
is the name of the subform control "sfInvestigation_Matrix" ?

to verify this...
open form "frmInvestigation_Detail" in design view
- select the outer edge of the subform, to access the subform control
   hit F4
   select the Other tab and look in the Name property
0
 

Author Comment

by:4GvnNot4Gotn
ID: 39205868
It is named sfInvestigation_Matrix.  Check, double-checked, tripled checked.  

I think I found out what is happening but couldn't find where it is published anywhere.  

Although you can reference fields in a footer whose visible property = No, if there is a sub-form in that footer, the visible = no prevents Access from being about to call the fields in the sub-form.  

I tested this by moving the sub-form into the detail section of the form, resizing it to it's smallest possible form factor and then executing the application.  When I did that, everything runs fine.  

This is confusing and not the solution that I was expecting but it is a work around that leaves a small object (which you can't hide behind the graphic) onscreen.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39205891
ok.i didn't see that part in your original post that the visible property of the subform is set to NO..

that is where you are getting the error from..
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:4GvnNot4Gotn
ID: 39205912
It is the main form footer that was set to visible = No. It also held the sub form.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39205916
try setting the visible = yes and test your codes.
0
 

Author Comment

by:4GvnNot4Gotn
ID: 39205977
Already did. It works but folds the screen. You can still access individual  objects in a flyer that is hidden but you can't access a sub form and it's fields.
0
 

Author Closing Comment

by:4GvnNot4Gotn
ID: 39362700
This was the key and I found it on my own.  You have to make the subform visible but resize it to its smallest form factor (looks like a square dot).  Take off the tab stop properties so you don't accidentally tab to it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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