Unable to use SetValue command

S

simon wong

Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light on me.
 
K

Ken Snell

You haven't posted an example of what you've tried, so I am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName
 
S

Simon

Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?

-----Original Message-----
You haven't posted an example of what you've tried, so I am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light on me.


.
 
T

tina

my motto is: if something won't work and you can't figure out why, just do
it some other way!
if you're willing to give up the macro approach and use a tiny bit of VBA
code, try this:

go to the form or control event where you are calling the macro.
delete the macro name from that event.
click the "down" arrow at the right side of the event line, and select
[Event Procedure] from the droplist.
click the ellipsis (...) button at the right of the event line.
Access will create a VBA procedure for you, and put the cursor between the
Private Sub and End Sub lines.
type the following line of code:

Me!ControlName = "the value you want to set for the control"

if the value is numeric, do not use the quotes ("").
go to the menu bar at the top of the VBA window, and click Debug, Compile.
if you get a compile error (probably you won't), post it here.

hth


Simon said:
Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?

-----Original Message-----
You haven't posted an example of what you've tried, so I am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light on me.


.
 
K

Ken Snell

Is your form's AllowEdits property set to Yes?

--
Ken Snell
<MS ACCESS MVP>

Simon said:
Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?

-----Original Message-----
You haven't posted an example of what you've tried, so I am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light on me.


.
 
S

Simon

Dear Ken

I have set the AllowEdits property to Yes, but still fail.


Best regards
Simon
-----Original Message-----
Is your form's AllowEdits property set to Yes?

--
Ken Snell
<MS ACCESS MVP>

Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?

-----Original Message-----
You haven't posted an example of what you've tried, so
I
am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

"simon wong" <[email protected]>
wrote
in message
Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light
on
me.


.
 
S

Simon

I have try your method, but can't work.

What I am trying to do is
On a form, a button is created
When the button got focus,
The characters on the button will change color from Black
to Red (with code 255, i guess)
So I turn on the property sheet belongs to the button
Go to the event page
Go to onfocus tab
Choose Eventprocedure as you suggested,
then write:
Me![Form]![Autoexec]![Command1]![Forecolor] = 255

When I try this out
An error mssg saying cannot locate [Form]


So any suggestion?

Best regards
Simon
-----Original Message-----
my motto is: if something won't work and you can't figure out why, just do
it some other way!
if you're willing to give up the macro approach and use a tiny bit of VBA
code, try this:

go to the form or control event where you are calling the macro.
delete the macro name from that event.
click the "down" arrow at the right side of the event line, and select
[Event Procedure] from the droplist.
click the ellipsis (...) button at the right of the event line.
Access will create a VBA procedure for you, and put the cursor between the
Private Sub and End Sub lines.
type the following line of code:

Me!ControlName = "the value you want to set for the control"

if the value is numeric, do not use the quotes ("").
go to the menu bar at the top of the VBA window, and click Debug, Compile.
if you get a compile error (probably you won't), post it here.

hth


Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?

-----Original Message-----
You haven't posted an example of what you've tried, so
I
am guessing that
your syntax is wrong. Try this as the "control name" argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

"simon wong" <[email protected]>
wrote
in message
Hi all

I have never suceed to set value by using SetValue command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my access
software where certain function has not been activated.

It will be very nice if someone can shed some light
on
me.


.
 
T

tina

sorry, i should have read your second post a little closer. try this:

in the button's On Got Focus event property, add the Event Procedure as i
described before.
put the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 255

255 = bright red. substitute the number of whatever color you want to see.

in the button's On Lost Focus event property, add an Event Procedure. put
the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 0

0 = black. substitute the number of the original color, to turn the
forecolor back to normal.

hth


Simon said:
I have try your method, but can't work.

What I am trying to do is
On a form, a button is created
When the button got focus,
The characters on the button will change color from Black
to Red (with code 255, i guess)
So I turn on the property sheet belongs to the button
Go to the event page
Go to onfocus tab
Choose Eventprocedure as you suggested,
then write:
Me![Form]![Autoexec]![Command1]![Forecolor] = 255

When I try this out
An error mssg saying cannot locate [Form]


So any suggestion?

Best regards
Simon
-----Original Message-----
my motto is: if something won't work and you can't figure out why, just do
it some other way!
if you're willing to give up the macro approach and use a tiny bit of VBA
code, try this:

go to the form or control event where you are calling the macro.
delete the macro name from that event.
click the "down" arrow at the right side of the event line, and select
[Event Procedure] from the droplist.
click the ellipsis (...) button at the right of the event line.
Access will create a VBA procedure for you, and put the cursor between the
Private Sub and End Sub lines.
type the following line of code:

Me!ControlName = "the value you want to set for the control"

if the value is numeric, do not use the quotes ("").
go to the menu bar at the top of the VBA window, and click Debug, Compile.
if you get a compile error (probably you won't), post it here.

hth


Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?


-----Original Message-----
You haven't posted an example of what you've tried, so I
am guessing that
your syntax is wrong. Try this as the "control name"
argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

in message
Hi all

I have never suceed to set value by using SetValue
command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element
about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my
access
software where certain function has not been activated.

It will be very nice if someone can shed some light on
me.



.


.
 
S

Simon

Hi Tina

Your suggestion work! Thanks a million.

Meantime do you think the same job can be accomplished by
using SetValue command in Macro?

I have no knowledge in VBA, and I think I will consider it
seriously to start learning VBA (which I think will be
painful).


Best regards
Simon
-----Original Message-----
sorry, i should have read your second post a little closer. try this:

in the button's On Got Focus event property, add the Event Procedure as i
described before.
put the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 255

255 = bright red. substitute the number of whatever color you want to see.

in the button's On Lost Focus event property, add an Event Procedure. put
the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 0

0 = black. substitute the number of the original color, to turn the
forecolor back to normal.

hth


I have try your method, but can't work.

What I am trying to do is
On a form, a button is created
When the button got focus,
The characters on the button will change color from Black
to Red (with code 255, i guess)
So I turn on the property sheet belongs to the button
Go to the event page
Go to onfocus tab
Choose Eventprocedure as you suggested,
then write:
Me![Form]![Autoexec]![Command1]![Forecolor] = 255

When I try this out
An error mssg saying cannot locate [Form]


So any suggestion?

Best regards
Simon
-----Original Message-----
my motto is: if something won't work and you can't figure out why, just do
it some other way!
if you're willing to give up the macro approach and
use a
tiny bit of VBA
code, try this:

go to the form or control event where you are calling
the
macro.
delete the macro name from that event.
click the "down" arrow at the right side of the event line, and select
[Event Procedure] from the droplist.
click the ellipsis (...) button at the right of the
event
line.
Access will create a VBA procedure for you, and put the cursor between the
Private Sub and End Sub lines.
type the following line of code:

Me!ControlName = "the value you want to set for the control"

if the value is numeric, do not use the quotes ("").
go to the menu bar at the top of the VBA window, and click Debug, Compile.
if you get a compile error (probably you won't), post
it
here.
hth


Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?


-----Original Message-----
You haven't posted an example of what you've tried,
so
I
am guessing that
your syntax is wrong. Try this as the "control name"
argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

in message
Hi all

I have never suceed to set value by using SetValue
command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element
about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my
access
software where certain function has not been activated.

It will be very nice if someone can shed some
light
on


.
 
T

tina

open the macro in design view, and try this:

in the Action column, choose SetValue

in the Action Arguments, set as follows:

Item: [Forms]![FormName]![CommandButtonName].[ForeColor]
Expression: 255

substitute the correct form name and command button name, of course.
add this macro to the command button's On Got Focus event, in place of the
Event Procedure.
don't forget to create a second macro to turn the color back to the default,
and add it in place of the Event Procedure on the On Lost Focus event.

fyi, when you have trouble with syntax in referencing an object, use the
builder wizard to build the expression - that's what i did here, because i
couldn't remember the correct syntax to reference the command button's
forecolor property in a macro (i normally use VBA). the builder can make
your life a lot easier.

hth


Simon said:
Hi Tina

Your suggestion work! Thanks a million.

Meantime do you think the same job can be accomplished by
using SetValue command in Macro?

I have no knowledge in VBA, and I think I will consider it
seriously to start learning VBA (which I think will be
painful).


Best regards
Simon
-----Original Message-----
sorry, i should have read your second post a little closer. try this:

in the button's On Got Focus event property, add the Event Procedure as i
described before.
put the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 255

255 = bright red. substitute the number of whatever color you want to see.

in the button's On Lost Focus event property, add an Event Procedure. put
the following line of code in the event procedure:

Screen.ActiveControl.ForeColor = 0

0 = black. substitute the number of the original color, to turn the
forecolor back to normal.

hth


I have try your method, but can't work.

What I am trying to do is
On a form, a button is created
When the button got focus,
The characters on the button will change color from Black
to Red (with code 255, i guess)
So I turn on the property sheet belongs to the button
Go to the event page
Go to onfocus tab
Choose Eventprocedure as you suggested,
then write:
Me![Form]![Autoexec]![Command1]![Forecolor] = 255

When I try this out
An error mssg saying cannot locate [Form]


So any suggestion?

Best regards
Simon
-----Original Message-----
my motto is: if something won't work and you can't
figure out why, just do
it some other way!
if you're willing to give up the macro approach and use a
tiny bit of VBA
code, try this:

go to the form or control event where you are calling the
macro.
delete the macro name from that event.
click the "down" arrow at the right side of the event
line, and select
[Event Procedure] from the droplist.
click the ellipsis (...) button at the right of the event
line.
Access will create a VBA procedure for you, and put the
cursor between the
Private Sub and End Sub lines.
type the following line of code:

Me!ControlName = "the value you want to set for the
control"

if the value is numeric, do not use the quotes ("").
go to the menu bar at the top of the VBA window, and
click Debug, Compile.
if you get a compile error (probably you won't), post it
here.

hth


message
Thank you for your info.

I have tried your suggestion before, as it is learned
from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?


-----Original Message-----
You haven't posted an example of what you've tried, so
I
am guessing that
your syntax is wrong. Try this as the "control name"
argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

"simon wong" <[email protected]>
wrote
in message
Hi all

I have never suceed to set value by using SetValue
command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set
the
property or method for an object. But this element
doesn't allow [automatic] operation to use this
property
or method. Check out documentation for the element
about
enabling [automatic] operation for property and
method.

'CLICK OK to continue'

I guess it is something to do with the set up of my
access
software where certain function has not been
activated.

It will be very nice if someone can shed some light
on
me.



.



.


.
 
K

Ken Snell

Simon -

After reading your posts elsewhere in this thread, I'm guessing that you are
putting the form reference in the textbox next to the event name in the
Properties window of the form in design view? This is not where you should
put that "code".

Instead, go to Macros in Database Window and create a new macro. Put the
step in the macro via the design grid. Save the macro with a name (say,
macSetMyValue). Then, in the form's design view, click the dropdown arrow in
the box next to the event name and select the macro name. That should do it.

--
Ken Snell
<MS ACCESS MVP>

Simon said:
Dear Ken

I have set the AllowEdits property to Yes, but still fail.


Best regards
Simon
-----Original Message-----
Is your form's AllowEdits property set to Yes?

--
Ken Snell
<MS ACCESS MVP>

Thank you for your info.

I have tried your suggestion before, as it is learned from
the Access user manual and the help topic. I tried
setting the control's property (change button's word's
color), and setting value for new records, using the
syntax suggested but they all return me the same error
mssage as mentioned in my earlier e-mail.

Any other suggestion?


-----Original Message-----
You haven't posted an example of what you've tried, so I
am guessing that
your syntax is wrong. Try this as the "control name"
argument:

Forms!FormName!ControlName


--
Ken Snell
<MS ACCESS MVP>

in message
Hi all

I have never suceed to set value by using SetValue
command
in macro. It always return the following error mssg
(which is my translation from Chinese)

START
Object doesn't contain auto object "Form"
You attempt to execute a Visual Basic steps to set the
property or method for an object. But this element
doesn't allow [automatic] operation to use this property
or method. Check out documentation for the element
about
enabling [automatic] operation for property and method.

'CLICK OK to continue'

I guess it is something to do with the set up of my
access
software where certain function has not been activated.

It will be very nice if someone can shed some light on
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

Top