?
Solved

Access 2013 - Call subform fields

Posted on 2013-05-29
7
Medium Priority
?
915 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
[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
  • 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 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