change decimal places in subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a form with a subform on it. The subform displays information
including an amount field. There are instances in which I would like to see
(& print) this form when the subform displays 6 decimal places, and there are
times that I'd like to see (& print) with only 1 decimal place. I would like
to call a function from either a button or a menu item to accomplish this.
In addition, there is a total textbox on the main form that sums the subform
info. I would like the same functionality for the textbox as well. Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but fails on
trying to change the subform. Any suggestions?
 
Thanks for the reply. I tried your suggestion and got error #2455 - Invalid
reference. I then tried your same suggestion with "Forms" instead of "Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around - although
tedious and time consuming - would be to create 2 forms for the same purpose
one with 6 decimals and one with 1.

Any other suggestions?

Douglas J Steele said:
Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access Web" for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
Hi,

I have a form with a subform on it. The subform displays information
including an amount field. There are instances in which I would like to see
(& print) this form when the subform displays 6 decimal places, and there are
times that I'd like to see (& print) with only 1 decimal place. I would like
to call a function from either a button or a menu item to accomplish this.
In addition, there is a total textbox on the main form that sums the subform
info. I would like the same functionality for the textbox as well. Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but fails on
trying to change the subform. Any suggestions?
 
Access has an annoying habit (at least, it's annoying to me!) of making the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
Thanks for the reply. I tried your suggestion and got error #2455 - Invalid
reference. I then tried your same suggestion with "Forms" instead of "Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around - although
tedious and time consuming - would be to create 2 forms for the same purpose
one with 6 decimals and one with 1.

Any other suggestions?

Douglas J Steele said:
Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access Web" for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
Hi,

I have a form with a subform on it. The subform displays information
including an amount field. There are instances in which I would like
to
see
(& print) this form when the subform displays 6 decimal places, and
there
are
times that I'd like to see (& print) with only 1 decimal place. I
would
like
to call a function from either a button or a menu item to accomplish this.
In addition, there is a total textbox on the main form that sums the subform
info. I would like the same functionality for the textbox as well. Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but fails on
trying to change the subform. Any suggestions?
 
No luck. I did check your reference and only tried "Forms" as a shot in the
dark. I'm still getting error 2455 - invalid reference on the line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

Thanks for helping - any more suggestions?


Douglas J Steele said:
Access has an annoying habit (at least, it's annoying to me!) of making the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
Thanks for the reply. I tried your suggestion and got error #2455 - Invalid
reference. I then tried your same suggestion with "Forms" instead of "Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around - although
tedious and time consuming - would be to create 2 forms for the same purpose
one with 6 decimals and one with 1.

Any other suggestions?

Douglas J Steele said:
Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access Web" for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays information
including an amount field. There are instances in which I would like to
see
(& print) this form when the subform displays 6 decimal places, and there
are
times that I'd like to see (& print) with only 1 decimal place. I would
like
to call a function from either a button or a menu item to accomplish this.
In addition, there is a total textbox on the main form that sums the
subform
info. I would like the same functionality for the textbox as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but fails on
trying to change the subform. Any suggestions?
 
What event are you putting that code in?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



kabaka said:
No luck. I did check your reference and only tried "Forms" as a shot in
the
dark. I'm still getting error 2455 - invalid reference on the line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

Thanks for helping - any more suggestions?


Douglas J Steele said:
Access has an annoying habit (at least, it's annoying to me!) of making
the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that
holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
Thanks for the reply. I tried your suggestion and got error #2455 - Invalid
reference. I then tried your same suggestion with "Forms" instead of "Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around - although
tedious and time consuming - would be to create 2 forms for the same purpose
one with 6 decimals and one with 1.

Any other suggestions?

:

Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access
Web" for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays
information
including an amount field. There are instances in which I would
like to
see
(& print) this form when the subform displays 6 decimal places, and there
are
times that I'd like to see (& print) with only 1 decimal place. I would
like
to call a function from either a button or a menu item to
accomplish this.
In addition, there is a total textbox on the main form that sums
the
subform
info. I would like the same functionality for the textbox as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but
fails on
trying to change the subform. Any suggestions?
 
At the moment, in the On_Click event of a button.



Douglas J. Steele said:
What event are you putting that code in?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



kabaka said:
No luck. I did check your reference and only tried "Forms" as a shot in
the
dark. I'm still getting error 2455 - invalid reference on the line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

Thanks for helping - any more suggestions?


Douglas J Steele said:
Access has an annoying habit (at least, it's annoying to me!) of making
the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that
holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the reply. I tried your suggestion and got error #2455 -
Invalid
reference. I then tried your same suggestion with "Forms" instead of
"Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around -
although
tedious and time consuming - would be to create 2 forms for the same
purpose
one with 6 decimals and one with 1.

Any other suggestions?

:

Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access
Web"
for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays
information
including an amount field. There are instances in which I would
like
to
see
(& print) this form when the subform displays 6 decimal places, and
there
are
times that I'd like to see (& print) with only 1 decimal place. I
would
like
to call a function from either a button or a menu item to
accomplish
this.
In addition, there is a total textbox on the main form that sums
the
subform
info. I would like the same functionality for the textbox as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but
fails
on
trying to change the subform. Any suggestions?
 
A button on the form, or on the subform?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
At the moment, in the On_Click event of a button.



Douglas J. Steele said:
What event are you putting that code in?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



kabaka said:
No luck. I did check your reference and only tried "Forms" as a shot in
the
dark. I'm still getting error 2455 - invalid reference on the line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

Thanks for helping - any more suggestions?


:

Access has an annoying habit (at least, it's annoying to me!) of making
the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that
holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the reply. I tried your suggestion and got error #2455 -
Invalid
reference. I then tried your same suggestion with "Forms" instead of
"Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around -
although
tedious and time consuming - would be to create 2 forms for the same
purpose
one with 6 decimals and one with 1.

Any other suggestions?

:

Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access
Web"
for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays
information
including an amount field. There are instances in which I would
like
to
see
(& print) this form when the subform displays 6 decimal places, and
there
are
times that I'd like to see (& print) with only 1 decimal place. I
would
like
to call a function from either a button or a menu item to
accomplish
this.
In addition, there is a total textbox on the main form that sums
the
subform
info. I would like the same functionality for the textbox as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but
fails
on
trying to change the subform. Any suggestions?
 
A button on the form, or on the subform?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
At the moment, in the On_Click event of a button.



Douglas J. Steele said:
What event are you putting that code in?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



No luck. I did check your reference and only tried "Forms" as a shot in
the
dark. I'm still getting error 2455 - invalid reference on the line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

Thanks for helping - any more suggestions?


:

Access has an annoying habit (at least, it's annoying to me!) of making
the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control to, say,
txtAmount and using

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control that
holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the reply. I tried your suggestion and got error #2455 -
Invalid
reference. I then tried your same suggestion with "Forms" instead of
"Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work around -
although
tedious and time consuming - would be to create 2 forms for the same
purpose
one with 6 decimals and one with 1.

Any other suggestions?

:

Try:

Forms![Asset Look Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The Access
Web"
for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays
information
including an amount field. There are instances in which I would
like
to
see
(& print) this form when the subform displays 6 decimal places, and
there
are
times that I'd like to see (& print) with only 1 decimal place. I
would
like
to call a function from either a button or a menu item to
accomplish
this.
In addition, there is a total textbox on the main form that sums
the
subform
info. I would like the same functionality for the textbox as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible = False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible = True
End Sub

This code works for changing the "Total" box to 1 decimal, but
fails
on
trying to change the subform. Any suggestions?
 
The syntax I showed worked for me in a test I just did.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



kabaka said:
A button on the form, or on the subform?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


kabaka said:
At the moment, in the On_Click event of a button.



:

What event are you putting that code in?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



No luck. I did check your reference and only tried "Forms" as a
shot in
the
dark. I'm still getting error 2455 - invalid reference on the
line:

Forms![Asset Look Ahead]![MySubForm].Form![txtAmount].DecimalPlaces
= 1

Thanks for helping - any more suggestions?


:

Access has an annoying habit (at least, it's annoying to me!) of making
the
name of the control the same as the field to which the control is bound.
Assuming that's the case here, see whether renaming the control
to, say,
txtAmount and using

Forms![Asset Look
Ahead]![MySubForm].Form![txtAmount].DecimalPlaces = 1

works. It may also be necessary to do the same with the control
that
holds
the subform.

(It definitely needs to be Form, not Forms: did you check the reference I
gave you?)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the reply. I tried your suggestion and got error #2455 -
Invalid
reference. I then tried your same suggestion with "Forms"
instead of
"Form"
and got error #438 - property not supported.

Does this imply that this cannot be done? My obvious work
around -
although
tedious and time consuming - would be to create 2 forms for the same
purpose
one with 6 decimals and one with 1.

Any other suggestions?

:

Try:

Forms![Asset Look
Ahead]![MySubForm].Form![Amount].DecimalPlaces = 1

Check http://www.mvps.org/access/forms/frm0031.htm at "The
Access
Web"
for
more about referring to controls on subforms.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have a form with a subform on it. The subform displays
information
including an amount field. There are instances in which I would
like
to
see
(& print) this form when the subform displays 6 decimal
places, and
there
are
times that I'd like to see (& print) with only 1 decimal
place. I
would
like
to call a function from either a button or a menu item to
accomplish
this.
In addition, there is a total textbox on the main form that sums
the
subform
info. I would like the same functionality for the textbox
as well.
Here's
where I'm at:

Private Sub test_Click()
Forms![Asset Look Ahead].Section("Detail").Visible =
False
Forms![Asset Look Ahead]![Total].DecimalPlaces = 1
Forms![Asset Look
Ahead]![MySubForm]![Amount].DecimalPlaces = 1
Forms![Asset Look Ahead].Section("Detail").Visible =
True
End Sub

This code works for changing the "Total" box to 1 decimal,
but
fails
on
trying to change the subform. Any suggestions?
 
Thanks for the help - I just figured it out. I simplified the syntax to
using "me"

Private Sub test_Click()
If Me.Total.DecimalPlaces = 1 Then
Me.Total.DecimalPlaces = 6
Me.MySubForm.Controls("txtAmount").DecimalPlaces = 6
Else
Me.Total.DecimalPlaces = 1
Me.MySubForm.Controls("txtAmount").DecimalPlaces = 1
End If
End Sub

With this working I should be able to move this code from being a sub for a
button to a generic function so that I can do this from a menu (which is more
ideal for my purposes).

Thanks for hanging in there with me!
 

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

Back
Top