option group fault

G

Guest

I have a main form (parent) which has a number of fields. It also has a tab
control. This has a number of headers including one called Invoicing. The
Invoicing Tab has a sub form called InvoiceTAB. From a field on the
InvoiceTAB subform I open another form so the user can input some data. On
this second form I have an option group which the user should select from and
it will do different things. Unfortunately the code I used comes up with an
error. The code is as follows:

Select Case Me.Frame17
Case 1 ' No invoice required shows textbox to input reason
TxtboxNoInvoice.Visible = True
Case 2 ' as per job description
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
DoCmd.Close
Case 3 ' as per child number
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.[child
subform]![Title]
DoCmd.Close
Case 4 ' as per invoice
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
MsgBox "cut and paste"
DoCmd.Close
Case 5 ' Stamp Duty
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me!Parent.[InvoiceTAB]![description] = "Stamp Duty"
Case 6 'other
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = True
End Select
End Sub
The error I get is when the code reaches:
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
The error states: The expression you have entered has an invalid reference
to the parent property
Can anyone help please
Thanks
 
K

Ken Snell \(MVP\)

Try changing this step:

Me.Parent.[InvoiceTAB]![description] = Me.Parent.description


to this step:

Me..[description] = Me.Parent.description
 
G

Guest

Me..[description] = Me.Parent.description would not allow
Me.[description] = Me.Parent.description same error invalid reference to
Parent property?
Not sure if it makes a big difference is the Parent.description is a text
box and the Parent.InvoiceTAB.description is a memo?


Ken Snell (MVP) said:
Try changing this step:

Me.Parent.[InvoiceTAB]![description] = Me.Parent.description


to this step:

Me..[description] = Me.Parent.description

--

Ken Snell
<MS ACCESS MVP>

Murray said:
I have a main form (parent) which has a number of fields. It also has a tab
control. This has a number of headers including one called Invoicing. The
Invoicing Tab has a sub form called InvoiceTAB. From a field on the
InvoiceTAB subform I open another form so the user can input some data. On
this second form I have an option group which the user should select from
and
it will do different things. Unfortunately the code I used comes up with
an
error. The code is as follows:

Select Case Me.Frame17
Case 1 ' No invoice required shows textbox to input reason
TxtboxNoInvoice.Visible = True
Case 2 ' as per job description
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
DoCmd.Close
Case 3 ' as per child number
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.[child
subform]![Title]
DoCmd.Close
Case 4 ' as per invoice
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
MsgBox "cut and paste"
DoCmd.Close
Case 5 ' Stamp Duty
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me!Parent.[InvoiceTAB]![description] = "Stamp Duty"
Case 6 'other
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = True
End Select
End Sub
The error I get is when the code reaches:
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
The error states: The expression you have entered has an invalid reference
to the parent property
Can anyone help please
Thanks
 
G

Graham Mandeno

Hi Murray

Are you saying that this code is in the second form (the one containing the
option group)? If so then it is not a subform and therefore has no parent.

To refer to the original form and its subform, you must use the Forms
collection. Let's say the name of the original form was frmJobDetails. You
should set up two Form object variables and assign them to the original form
and the subform respectively:

Dim frmJobs as Form
Dim frmInvoice as Form

Set frmJobs = Forms("frmJobDetails")
Set frmInvioce = frmJobs!InvoiceTAB.Form

Then you can use code such as:

frmInvoice!Description = frmJobs!Description
 
G

Guest

Graham,
Thanks for the reply, you are correct in where the option group sit (the
second form), the original form is called Parent and has the tab control.
Maybe the problem is labelling the form Parent?

Graham Mandeno said:
Hi Murray

Are you saying that this code is in the second form (the one containing the
option group)? If so then it is not a subform and therefore has no parent.

To refer to the original form and its subform, you must use the Forms
collection. Let's say the name of the original form was frmJobDetails. You
should set up two Form object variables and assign them to the original form
and the subform respectively:

Dim frmJobs as Form
Dim frmInvoice as Form

Set frmJobs = Forms("frmJobDetails")
Set frmInvioce = frmJobs!InvoiceTAB.Form

Then you can use code such as:

frmInvoice!Description = frmJobs!Description
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Murray said:
I have a main form (parent) which has a number of fields. It also has a tab
control. This has a number of headers including one called Invoicing. The
Invoicing Tab has a sub form called InvoiceTAB. From a field on the
InvoiceTAB subform I open another form so the user can input some data. On
this second form I have an option group which the user should select from
and
it will do different things. Unfortunately the code I used comes up with
an
error. The code is as follows:

Select Case Me.Frame17
Case 1 ' No invoice required shows textbox to input reason
TxtboxNoInvoice.Visible = True
Case 2 ' as per job description
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
DoCmd.Close
Case 3 ' as per child number
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.[child
subform]![Title]
DoCmd.Close
Case 4 ' as per invoice
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
MsgBox "cut and paste"
DoCmd.Close
Case 5 ' Stamp Duty
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me!Parent.[InvoiceTAB]![description] = "Stamp Duty"
Case 6 'other
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = True
End Select
End Sub
The error I get is when the code reaches:
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
The error states: The expression you have entered has an invalid reference
to the parent property
Can anyone help please
Thanks
 
G

Graham Mandeno

Hi Murray

I can't say for certain that there would be problems naming a form "Parent",
but it is certainly something I would avoid!

The problem here is a confusion involving object names and property names
and general syntax.

Me.Parent does not refer to a form named "Parent". "Me" refers to the class
in which your code is running - in this case your second form. The "Parent"
property, when applied to a given form, refers to the form that contains
that form as a subform. It is therefore valid only in the context of a
subform. As your second form is not a subform, then Me.Parent does not
exist - hence the "invalid reference to Parent property" error.

If you wish to refer to an open form which happens to be named "Parent",
then use Forms("Parent").

So the line in my code should be modified to:
Set frmJobs = Forms("Parent")

But I still recommend you change the name :)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Murray said:
Graham,
Thanks for the reply, you are correct in where the option group sit (the
second form), the original form is called Parent and has the tab control.
Maybe the problem is labelling the form Parent?

Graham Mandeno said:
Hi Murray

Are you saying that this code is in the second form (the one containing
the
option group)? If so then it is not a subform and therefore has no
parent.

To refer to the original form and its subform, you must use the Forms
collection. Let's say the name of the original form was frmJobDetails.
You
should set up two Form object variables and assign them to the original
form
and the subform respectively:

Dim frmJobs as Form
Dim frmInvoice as Form

Set frmJobs = Forms("frmJobDetails")
Set frmInvioce = frmJobs!InvoiceTAB.Form

Then you can use code such as:

frmInvoice!Description = frmJobs!Description
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Murray said:
I have a main form (parent) which has a number of fields. It also has a
tab
control. This has a number of headers including one called Invoicing.
The
Invoicing Tab has a sub form called InvoiceTAB. From a field on the
InvoiceTAB subform I open another form so the user can input some data.
On
this second form I have an option group which the user should select
from
and
it will do different things. Unfortunately the code I used comes up
with
an
error. The code is as follows:

Select Case Me.Frame17
Case 1 ' No invoice required shows textbox to input reason
TxtboxNoInvoice.Visible = True
Case 2 ' as per job description
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
DoCmd.Close
Case 3 ' as per child number
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me.Parent.[InvoiceTAB]![description] = Me.Parent.[child
subform]![Title]
DoCmd.Close
Case 4 ' as per invoice
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
MsgBox "cut and paste"
DoCmd.Close
Case 5 ' Stamp Duty
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = False
Me!Parent.[InvoiceTAB]![description] = "Stamp Duty"
Case 6 'other
TxtboxNoInvoice.Visible = False
TxtBoxOther.Visible = True
End Select
End Sub
The error I get is when the code reaches:
Me.Parent.[InvoiceTAB]![description] = Me.Parent.description
The error states: The expression you have entered has an invalid
reference
to the parent property
Can anyone help please
Thanks
 

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