Access 2003 Public Property Get

  • Thread starter Thread starter ag20
  • Start date Start date
A

ag20

I am having a problem with Access 2003.

I have a form "Form1" with

Public Property Get abc() As String
abc = "ABC"
End Property

I have a text box on the form and when I set the default property to

=[abc]

and run the form I get "#Name?" in the text box.

On my Access 97 and Access 2000 the "ABC" always shows up
when I run the form.

What do I have to do to get this to work?
 
ag20 said:
I am having a problem with Access 2003.

I have a form "Form1" with

Public Property Get abc() As String
abc = "ABC"
End Property

I have a text box on the form and when I set the default property to

=[abc]

and run the form I get "#Name?" in the text box.

On my Access 97 and Access 2000 the "ABC" always shows up
when I run the form.

What do I have to do to get this to work?

The name of the text box isn't "abc", is it? If that's not the problem,
does it work if you set the controlsource to

=[Form].[abc]

?
 
I am having a problem with Access 2003.

I have a form "Form1" with

Public Property Get abc() As String
abc = "ABC"
End Property

I have a text box on the form and when I set the default property to

=[abc]

and run the form I get "#Name?" in the text box.

On my Access 97 and Access 2000 the "ABC" always shows up
when I run the form.

What do I have to do to get this to work?

Hi,

When used in this manner, user defined properties are being blocked by Jet
sandbox mode expression blocking. We are aware of this problem and are
investigating it.

In the mean time, you can workaround this issue in two ways depending on
your needs.

1. Use a Function instead of a Property.

Change your Property Get statement to a Function statement as follows:

Public Function abc() as String

abc = "ABC"

End Function

Then in your form:

DefaultValue =abc()

2. Wrap your Property in a Function.

Granted, this is pretty much the same thing, just more code.

Public Function Get_abc() as String

Get_abc = abc

End Function

Then in your form:

DefaultValue =Get_abc()

Which one you use is largly a matter of how dependent you are on having a
Property exposed in other areas of your code.

--
Regards,
Mike Wachal
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for the insite. I also found the "tool/macro/security/low" setting,
and my applications work fine with that. I know that it's probably not
the safest thing to do but I have relied heavly on properties to pass
information
between forms and queries.

Mike Wachal said:
I am having a problem with Access 2003.

I have a form "Form1" with

Public Property Get abc() As String
abc = "ABC"
End Property

I have a text box on the form and when I set the default property to

=[abc]

and run the form I get "#Name?" in the text box.

On my Access 97 and Access 2000 the "ABC" always shows up
when I run the form.

What do I have to do to get this to work?

Hi,

When used in this manner, user defined properties are being blocked by Jet
sandbox mode expression blocking. We are aware of this problem and are
investigating it.

In the mean time, you can workaround this issue in two ways depending on
your needs.

1. Use a Function instead of a Property.

Change your Property Get statement to a Function statement as follows:

Public Function abc() as String

abc = "ABC"

End Function

Then in your form:

DefaultValue =abc()

2. Wrap your Property in a Function.

Granted, this is pretty much the same thing, just more code.

Public Function Get_abc() as String

Get_abc = abc

End Function

Then in your form:

DefaultValue =Get_abc()

Which one you use is largly a matter of how dependent you are on having a
Property exposed in other areas of your code.

--
Regards,
Mike Wachal
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Back
Top