Run-time error '2101' (1 Viewer)

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
This message - Run-time error '2101'... - is raised when double clicking a field on a form, to open another form.

Full message:

Run-time error '2102'
The form name '[Product Transactions View Subform]' is misspelled or refers to a form that doesn't exist.


The form exists, opens as a Display form and opens when clicked directly, and is spelled correctly.

Same process is used with two other forms in the same app w/o the message being raised.

Here's the code behind the double click:

DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "[ProductID=" & Me.[ProductID]

Looking at the code when the message is raised, Me.[ProductID] contains the selected valve.

I've deleted the initial form and created a new form and tried various form property settings.

And I've imported all objects into a new container as well as scoured the threads, implementing some of the suggestions to no avail.

Access 2016.

What am I missing?
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 19:25
Joined
Sep 21, 2011
Messages
14,310
And that error is what? What is the text description?
 

plog

Banishment Pending
Local time
Today, 13:25
Joined
May 11, 2011
Messages
11,646
Code:
DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "[ProductID=" & Me.[ProductID]

First off, i see 3 left brackets and 2 right brackets.

Then from there, my guess is you don't need brackets around the form name, unless that form name actually has brackets. Of course, I'm not entirely certain that's correct because I avoid spaces in object and field names like the plague so I can avoid this whole bracket/no bracket issue.

Those spaces in your form name are the real culprit.
 

moke123

AWF VIP
Local time
Today, 14:25
Joined
Jan 11, 2013
Messages
3,920
Gotta ask, Why does the form have subform in it's name?
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
And that error is what? What is the text description?
Modified the statement to the following:

DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "ProductID=" & Me.ProductID

The error message in Post #1 is raised.

Removed the brackets ( [ ] ) to this statement:

DoCmd.OpenForm "Product Transactions View Subform", acNormal, , "ProductID=" & Me.ProductID

And that raised a different message:

First, an Enter Parameter Value message box comes up with a 'W' showing above the field where one can enter a value.

Clicking OK w/o a valve in the field returns the following message:

Run-time error '3701':
The expression is typed incorrectly or is too complex to be evaluated. For example, a numeric expression may contain too many colplicaed elements. Try simplifying the expression by assigning parts of the expression to variables.
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
Code:
DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "[ProductID=" & Me.[ProductID]

First off, i see 3 left brackets and 2 right brackets.

Then from there, my guess is you don't need brackets around the form name, unless that form name actually has brackets. Of course, I'm not entirely certain that's correct because I avoid spaces in object and field names like the plague so I can avoid this whole bracket/no bracket issue.

Those spaces in your form name are the real culprit.

Appreciate you finding the missing bracket.
 

plog

Banishment Pending
Local time
Today, 13:25
Joined
May 11, 2011
Messages
11,646
What happens when you directly open "Product Transactions View Subform" by double clicking on it? Do you get the error message that way? If so your VBA is good, but your form's datasource is bad.
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
What happens when you directly open "Product Transactions View Subform" by double clicking on it? Do you get the error message that way? If so your VBA is good, but your form's datasource is bad.

Form opens correctly when clicked directly and 1) displays all of the data or, 2) if there is a request for a parameter, just the requested record.
 

plog

Banishment Pending
Local time
Today, 13:25
Joined
May 11, 2011
Messages
11,646
I don't understand how there are 2 unique situations when you double click the form. Under what circumstances does #1 happen? #2?
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
#1 is when there isn't a parameter request for the query. All of the records display.

#2 is when there is a prompt in the query for a unique criterion (valve) raised after clicking the form. When a valid value is entered the unique record will display in the form.
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
Code:
DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "[ProductID=" & Me.[ProductID]

First off, i see 3 left brackets and 2 right brackets.

Then from there, my guess is you don't need brackets around the form name, unless that form name actually has brackets. Of course, I'm not entirely certain that's correct because I avoid spaces in object and field names like the plague so I can avoid this whole bracket/no bracket issue.

Those spaces in your form name are the real culprit.
Renamed the form w/o spaces.

New error message:

Run-time error '3463':

Data type mismatch in criteria expression.

The ProductID is a text field.

The field on both forms are Plain Text.
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
I'm through for the day; this has consumed a lot of time and I'll look at again in the morning.

Appreciate the time and thought all have offered.

Thank you!
 

plog

Banishment Pending
Local time
Today, 13:25
Joined
May 11, 2011
Messages
11,646
I still don't understand how clicking on the form name can produce 2 different results.
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
I still don't understand how clicking on the form name can produce 2 different results.

#1 has the query set at no parameters so all of the records are displayed.

#2 raises a small form requesting data input and any records with a matching valve are returned.
 

LarryE

Active member
Local time
Today, 11:25
Joined
Aug 18, 2021
Messages
591
This message - Run-time error '2101'... - is raised when double clicking a field on a form, to open another form.

Full message:

Run-time error '2102'
The form name '[Product Transactions View Subform]' is misspelled or refers to a form that doesn't exist.


The form exists, opens as a Display form and opens when clicked directly, and is spelled correctly.

Same process is used with two other forms in the same app w/o the message being raised.

Here's the code behind the double click:

DoCmd.OpenForm "[Product Transactions View Subform]", acNormal, , "[ProductID=" & Me.[ProductID]

Looking at the code when the message is raised, Me.[ProductID] contains the selected valve.

I've deleted the initial form and created a new form and tried various form property settings.

And I've imported all objects into a new container as well as scoured the threads, implementing some of the suggestions to no avail.

Access 2016.

What am I missing?
DoCmd.OpenForm "Product Transactions View Subform", acNormal, , "[ProductID]=" & Me.ProductID &"
 

isladogs

MVP / VIP
Local time
Today, 19:25
Joined
Jan 14, 2017
Messages
18,227
In post #11 you said ProductID is a text field so use
Code:
DoCmd.OpenForm "Product Transactions View Subform", , , "ProductID='" & Me.ProductID & "'"
acNormal is the default and can be omitted
 

TedSla

New member
Local time
Today, 11:25
Joined
Nov 9, 2018
Messages
16
In post #11 you said ProductID is a text field so use
Code:
DoCmd.OpenForm "Product Transactions View Subform", , , "ProductID='" & Me.ProductID & "'"
acNormal is the default and can be omitted
That fixed the problem.

Thank you; much appreciated.
 

Users who are viewing this thread

Top Bottom