Setting the format property on a subform

H

HelenJ

I am trying to set the format on a field on a subform depending on a value on
the main form, using the following code:

Private Sub Form_Open(Cancel As Integer)
If Forms![SupplierRangeFm]![SupCurrency] = "£" Then
Me.ChargeC.Format = "Currency"
Else
Me.ChargeC.Format = "Euro"
End If
End Sub

However I get a complie error: Method or data memeber not found - it seems
the only attribute I have for the field is .value

I've tried putting the code at various other triggers (eg after the field
update) but I get the same result.

Can anyone shed light on what I am doing wrong (I have it working fine on
another subform!)

Thanks
 
H

HelenJ

I can get a value for the supCurrency no problem - but if I try to check the
format of the chargec field I get a run time error 438 - Object doesn't
support this property or method. I can check the value for the field fine -
so it is still the problem that for some reason I can't access the format of
this field (it is a bound field btw)

bhicks11 via AccessMonster.com said:
Hi Helen,

It works for me here. Is the SupCurrency control text? Try looking at the
values, format, etc., in the Immediate Window in the VB editor. Maybe it
will shed some light. Open it while the form is active and do:

?Forms![SupplierRangeFm]![SupCurrency] .value

or

?Forms![SupplierRangeFm]![SubForm].form.chargeC.format

Bonnie
http://www.dataplus-svc.com


I am trying to set the format on a field on a subform depending on a value on
the main form, using the following code:

Private Sub Form_Open(Cancel As Integer)
If Forms![SupplierRangeFm]![SupCurrency] = "£" Then
Me.ChargeC.Format = "Currency"
Else
Me.ChargeC.Format = "Euro"
End If
End Sub

However I get a complie error: Method or data memeber not found - it seems
the only attribute I have for the field is .value

I've tried putting the code at various other triggers (eg after the field
update) but I get the same result.

Can anyone shed light on what I am doing wrong (I have it working fine on
another subform!)

Thanks
 
H

HelenJ

The field is currency, but I have tried changing it's formatting eg setting
it as a general number, but it makes no difference I still can't get access
to it's format property when I try to code it.

Odd and very frustrating - I may have to just display the currency at the
top of the form and remove any currency symbols on the fields, which is not
ideal!

bhicks11 via AccessMonster.com said:
What type of field is it bound to? What is the default format for the
control? If you aren't setting the format property from the control, try
setting it and see if it then is available.

Bonnie
http://www.dataplus-svc.com
I can get a value for the supCurrency no problem - but if I try to check the
format of the chargec field I get a run time error 438 - Object doesn't
support this property or method. I can check the value for the field fine -
so it is still the problem that for some reason I can't access the format of
this field (it is a bound field btw)
Hi Helen,
[quoted text clipped - 32 lines]
 
H

HelenJ

Thanks for trying (I'm also in 2003 and it works on one form but not on this
one :-( ) Maybe someone else will have an idea....

bhicks11 via AccessMonster.com said:
Sorry Helen, I don't know why. I am in 2003 for what it's worth and works
for me.

Bonnie
http://www.dataplus-svc.com
The field is currency, but I have tried changing it's formatting eg setting
it as a general number, but it makes no difference I still can't get access
to it's format property when I try to code it.

Odd and very frustrating - I may have to just display the currency at the
top of the form and remove any currency symbols on the fields, which is not
ideal!
What type of field is it bound to? What is the default format for the
control? If you aren't setting the format property from the control, try
[quoted text clipped - 14 lines]
 
D

Dirk Goldgar

HelenJ said:
I am trying to set the format on a field on a subform depending on a value
on
the main form, using the following code:

Private Sub Form_Open(Cancel As Integer)
If Forms![SupplierRangeFm]![SupCurrency] = "£" Then
Me.ChargeC.Format = "Currency"
Else
Me.ChargeC.Format = "Euro"
End If
End Sub

However I get a complie error: Method or data memeber not found - it seems
the only attribute I have for the field is .value

That implies that "ChargeC" is not the name of any control on the form,
though it is the name of a field in the form's recordsource. Do you
actually have a control bound to this field? Assuming you do, my guess is
that the name of the control is not the same as the name of the field.
Check the name of that control, and use that name in your code.
 

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