0

I have a Form in wich I enter some values (project info)

ProjectInfo

The values entered in these fields, are stored in some variables in VBA when the user clicks the button:

Private Sub btnPItoKabels_Click()

    Dim Project As String
    Dim ProjectNummer As String
    Dim OpdrachtGever As String

    Project = ProjectInvoer.Value
    ProjectNummer = ProjectNrInvoer.Value
    OpdrachtGever = OpdrachtgeverInvoer.Value

    DoCmd.OpenForm "frmMain", acNormal, , , acFormAdd
    DoCmd.Close acForm, "frmProjectInvoer", acSaveNo

End Sub

Now I would like to retrieve these values in a few reports I have (they will appear in the header)

Header

These are just regular text fields.

How can I retrieve the values from the three strings and put them in these fields?

2
  • Your question is not quite clear, do you wish to store these values in a table, do a series of reports run on the back of you clicking this form's OK button? How is it the Reports relate to this form? Commented Jun 19, 2013 at 8:34
  • @MattDonnan the first picture is a Form in wich a user can insert the project info, the reports are related to the form in that the reports that are printed have a header in wich I want the project info Commented Jun 19, 2013 at 8:47

3 Answers 3

1

It's not easy to say which setup will work best for you, I suggest amending your OK button to run the reports in question.

In your reports design set for example the Project header field to:

=Forms!frmProjectInvoer!ProjectInvoer

This will then reference the values entered in your form when you open your reports, note you do not need to add the .Value to the end of the fieldname

Sign up to request clarification or add additional context in comments.

Comments

1

If your form is not closed, you can easily reference them with the formula "=Forms!MyFormName!Project" (or whichever textbox you're referencing). If you plan to close the form, you can't really reference the values unless you specify them as GLOBAL, but even so they only last while the current sub is running.

Comments

0

I have done the following to solve the problem:

when pressing the "ok" button, the values in the form will be put in a new table "tempProjectInfo"

When loading the reports, the values are taken from the table and the table is dropped.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.