Mirume
Mirume

Reputation: 73

MS Access: Unbound fields in a subform not showing on a report

I'm having a bit of trouble figuring out how to fix an issue with my MS Access database report output.

First: There are three forms, one of which is for navigation purposes (HOME) that has two navigation buttons in a navigation control (which link to either of the two other forms) and on subform field I use much like an iframe. There are also two reports, one for each of the other forms.

Second: Both forms have unbound text fields that need to be printed onto the report output. There is no need for these fields to be saved or put into a table. The values of these forms are printed without issue when the form is isolated (i.e.- modal, form view, etc.). The unbound fields are part of the main body of the form where controlled fields are located.

Only when a form is viewed in the "HOME" form in the subform box/iframe does the report show #Name? instead of their intended values. Also worth noting, the subform does not have the Link Master Fields or Link Child Fields options.

The code used on the print command object/button is as follows and is located on the footer of the non-HOME forms:

Private Sub cmdPrint_Click()
    Dim strWhere As String

    If Me.NewRecord Then 'Check there is a record to print
        MsgBox "Select a record to print"
    Else
        strWhere = "[CustomerID] = " & Me.[CustomerID]
        DoCmd.OpenReport "TransferAgreement_EC", acViewPreview, , strWhere
    End If
End Sub

Any suggestions? I tried searching here and Googled the issue, but I haven't quite found the solution to my problem. Thanks in advance for your input!

Upvotes: 0

Views: 1504

Answers (1)

Mirume
Mirume

Reputation: 73

Okay. So, found the solution by just running a whole lot of experiments and this fixed it.

On the report itself, on the data field needs to call to both the navigation form and the subnavigation box, then point to the unbound field. For example, one field in the control source is:

=[Forms]![Home]![NavigationSubform].[Form]![GCSerial_1]
  • Home = The navigation form
  • NavigationSubform = The nagivation subform box (what I consider an "iframe")
  • Form = Just a call to to a form, not specific
  • GCSerial_1 = The unbound text field

In this way, the report will not print the unbound fields when it is not a subform of the navigation form. For example, by default my two other forms are modal pop ups. When I "form view" them as modal prompts, the unbound fields display #Name? when I click my print command button, which specifies a report (no longer) contingent on a subform and not an isolated form.

THANKS FOR THE HELP AND INSPIRATION! <3

Upvotes: 0

Related Questions