Subform Woes

G

Gitche Gumee

The following code works fine when I am navigating from record to record.

On Current:
If Not IsNull(Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn) Then
Me.cboProductGroupFunction = DLookup("ProductGroupFunction",
"tblProductGroupFunction", "ProductGroupID = " & Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Me.cboProduct = DLookup("Product", "tblProductGroupFunction",
"ProductGroupID = " & Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Else
Me.cboProductGroupFunction = ""
Me.cboProduct = ""
End If

However, if I open a form to add a new record and then close it, I get the
following error:
Run-Time Error 2455: You entered an expression that has an invalid reference
to the property Form/Report.
The first line ("If....Then") is highlighted.

If I click "End" instead of "Debug" the form appears and functions normally.

What's the problem?
 
G

Gitche Gumee

Never mind. Upon further review, I discovered the solution: error handling to
ignore error 2455.

Thanks.
 
B

BruceM

You have a syntax problem that is not going to go away if you ignore the
error message. The syntax for referring to a control or field on a subform
is:
Forms!MainFormName!SubformControlName.Form!FieldName

Gitche Gumee said:
Never mind. Upon further review, I discovered the solution: error handling
to
ignore error 2455.

Thanks.

Gitche Gumee said:
The following code works fine when I am navigating from record to record.

On Current:
If Not IsNull(Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Then
Me.cboProductGroupFunction = DLookup("ProductGroupFunction",
"tblProductGroupFunction", "ProductGroupID = " & Forms!frmMain![frm
Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Me.cboProduct = DLookup("Product", "tblProductGroupFunction",
"ProductGroupID = " & Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Else
Me.cboProductGroupFunction = ""
Me.cboProduct = ""
End If

However, if I open a form to add a new record and then close it, I get
the
following error:
Run-Time Error 2455: You entered an expression that has an invalid
reference
to the property Form/Report.
The first line ("If....Then") is highlighted.

If I click "End" instead of "Debug" the form appears and functions
normally.

What's the problem?
 
G

Gitche Gumee

I got the same error with the syntax you provided. The error occurs because
the subform loads before the main forms Current event. I am following Allen
Browne's advice to ignore the error.

BruceM said:
You have a syntax problem that is not going to go away if you ignore the
error message. The syntax for referring to a control or field on a subform
is:
Forms!MainFormName!SubformControlName.Form!FieldName

Gitche Gumee said:
Never mind. Upon further review, I discovered the solution: error handling
to
ignore error 2455.

Thanks.

Gitche Gumee said:
The following code works fine when I am navigating from record to record.

On Current:
If Not IsNull(Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Then
Me.cboProductGroupFunction = DLookup("ProductGroupFunction",
"tblProductGroupFunction", "ProductGroupID = " & Forms!frmMain![frm
Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Me.cboProduct = DLookup("Product", "tblProductGroupFunction",
"ProductGroupID = " & Forms!frmMain![frm Project
Information]![tblProjectProductGroupJctn subform1]!ProductGroupIDJctn)
Else
Me.cboProductGroupFunction = ""
Me.cboProduct = ""
End If

However, if I open a form to add a new record and then close it, I get
the
following error:
Run-Time Error 2455: You entered an expression that has an invalid
reference
to the property Form/Report.
The first line ("If....Then") is highlighted.

If I click "End" instead of "Debug" the form appears and functions
normally.

What's the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top