Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access cannot find the referenced form

Tags:

vba

ms-access

I am in the final stages of testing a small piece of software I made, and am experiencing a Access cannot find the referenced form 'Customer Picker':

enter image description here

I've checked over my syntax for accessing the form, and there's nothing wrong with it. I've also looked for a solution to this (this issue being well documented on Stack Overflow) but nothing has worked.

This is the (partial) code I'm using:

DoCmd.OpenReport "Invoice", acViewPreview
If (Forms![Customer Picker]![Combo3].Value = "Business") Then
    Reports![Invoice]![Text154] = Forms![Customer Picker]![Text8]
Else
    Reports![Invoice]![Text154] = Forms![Customer Picker]![Text10] + " " + Forms![Customer Picker]![Text6]
End If

My objective is to populate a report based on the information entered in the form, and then print the report (haven't got as far as that yet).

What am I doing wrong here, and how can I fix this?

like image 439
AStopher Avatar asked Nov 02 '25 12:11

AStopher


1 Answers

You can only reference Forms![Customer Picker] when the form is open. But you reported that CurrentProject.AllForms("Customer Picker").IsLoaded returned False.

If it is included as a subform in some other form which is open, you can reference it via the name of the subform control on that other form:

Forms![Other Form]![Subform Control]![Text8]

Note that the name of the subform control may not be the same as the name of the form which it contains.

like image 107
HansUp Avatar answered Nov 04 '25 06:11

HansUp