|
|
|
date: Mon, 4 Aug 2008 03:27:01 -0700,
group: microsoft.public.access.macros
back
Re: Using the SetProperty Macro action in a subform
Temp PO Item Query Subform is nested in 'Temp PO Main Query' form. Perhaps i
need to select the subform as a control of the main form first?
Form: Temp PO Item Query Subform
Control Name: Cost
Event: On Change (run macro)
Action: SetValue
Arguments: Cost, Fore Colour, Black
Error Header: The Control name "Cost" is misspelled or refers to a control
that does not exist.
With select object...
Form: Temp PO Item Query Subform
Control Name: Cost
Event: On Change (run macro)
Action1: Select Object
Arguments1: Temp PO Item Query Subform
Action2: SetValue
Arguments2: Cost, Fore Colour, Black
Error Header: Object "Temp PO Item Query Subform is not open" (or something
to that effect)
Thanks for the pointers steve
"Steve Schapel" wrote:
> Nick,
>
> I think you will need to give more specific details before anyone can
> give a meaningful answer here.
>
> What is the name of the control? What is the name of the form? What is
> the name of the subform? What Event is the macro running on (there is
> no such thing as Upon Change). What are the exact details of the macro,
> i.e. Actiosn and Arguments. What is the exact wording of the error
> message? Etc.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Access Newbie Nick wrote:
> > When setting the font colour of a control in a subform Upon Change, i get an
> > error message about an incorrect control name. The name is correct, the macro
> > is embedded, and when i add SelectObject for the subform it says it is not
> > open, probably bc it is within another form.
> > Is there any way to get around this without using Code or Opening the form
> > seperately?
> > Any help is greatly appreciated!
>
date: Mon, 4 Aug 2008 04:26:01 -0700
author: Access Newbie Nick
Re: Using the SetProperty Macro action in a subform
Nick,
Probably the On Change event is not really appropriate here. Sorry to
pepper you with questions, but... the Change event of what? Of a
control? If so, is this control on the main form of the subform?
Without knowing quite what you are trying to achieve, I would guess that
you are running the macro on a control on the main form, and I expect
the After Update event is possibly more applicable.
And the Cost control is on the subform, right?
Ok, if my assumptions are correct, try it like this:
Action: SetValue
Item: [Temp PO Item Query Subform].[Form]![Cost].[ForeColor]
Expression: Black
Having said that, I should also comment that you are probably doing this
the hard way. You can probably use Conditional Formatting to achieve
what you want here, with less effort. :-)
--
Steve Schapel, Microsoft Access MVP
Access Newbie Nick wrote:
> Temp PO Item Query Subform is nested in 'Temp PO Main Query' form. Perhaps i
> need to select the subform as a control of the main form first?
>
> Form: Temp PO Item Query Subform
> Control Name: Cost
> Event: On Change (run macro)
> Action: SetValue
> Arguments: Cost, Fore Colour, Black
>
> Error Header: The Control name "Cost" is misspelled or refers to a control
> that does not exist.
>
> With select object...
>
> Form: Temp PO Item Query Subform
> Control Name: Cost
> Event: On Change (run macro)
> Action1: Select Object
> Arguments1: Temp PO Item Query Subform
> Action2: SetValue
> Arguments2: Cost, Fore Colour, Black
>
> Error Header: Object "Temp PO Item Query Subform is not open" (or something
> to that effect)
date: Tue, 05 Aug 2008 11:42:00 +1200
author: Steve Schapel
Re: Using the SetProperty Macro action in a subform
Nick,
You have misunderstood the meaning of the On Change event. Now that you
have explained a bit more, I strongly recommend you review this practice.
I understand the situation with the form and subform. That's why I made
my earlier suggestion about the syntax to use for the Item argument of
your SetValue action. Did you try it? How did it go?
You are incorrect in your statement about Conditional Formatting.
--
Steve Schapel, Microsoft Access MVP
Access Newbie Nick wrote:
> Thanks for the input again. The on Change i think is appropriate for me as i
> want the colour to change as soon as the user changes the information in a
> field, i think i also tried the macro in after update also but to the same
> affect. Basically it is a copy of a previous record, many things may be the
> same but some may be different, so i want the text to be red if unchanged, so
> the user is aware that it may need to be changed. The macro runs at the
> correct time, and i have no problems running a similar macro in the main
> form. The problem only arises from it being a subform and therefore access
> doesnt seem to acknoledge that the subform is infact open. The On Change
> Event that begins the macro is on the control that is being changed itself.
> Conditional formatting couldnt be used in this case i think: There is no
> expression or value that would make it dependant on the information in the
> control being changed.
> In Short the instigaion of the macro is not such a problem, but the running
> of the macro in a subform throws up problems of finding the control.
date: Wed, 06 Aug 2008 08:15:56 +1200
author: Steve Schapel
Re: Using the SetProperty Macro action in a subform
Nick,
You are not bothering me. :-)
But equally, you are not helping me! :-) You're not relating to the idea
that I'm not looking over your shoulder at your database. I need more
information. I asked you what control you are evaluating, and where it
is, but you didn't answer that. I am guessing you have a control on the
main form, and you want its value to toggle the colour of the Cost
control on the subform. But you haven't confirmed this suspicion. And
now you are asking me to suggest a Conditional Formatting expression
without me knowing anything about what control it is or what your
conditions are or what kind of data it has or anything.
As for the 'Black', I'm sorry I was wrong about that. I think it will
work to use the numerical value for black, which is 0.
--
Steve Schapel, Microsoft Access MVP
Access Newbie Nick wrote:
> Ahhh ok then. So After Update would be better it seems. I tried the
> suggestion you gave me, however the 'Black' is automatically changed to
> '[Black]', and the message appears as follows-
>
> ------
> The object doesn't contain the Automaton object 'Black'
>
> You tried to ru a Visual Basic procedure to set a property or method for an
> object. However, the component doesn't make the property or method available
> for Automation operations.
>
> Check the component's documentation for information on the properties and
> methods it makes available for Automation operations.
> ------
>
> Also if i could use conditional formatting that would be a lot easier
> definately, so if you have a suggestion for an expression i can use then by
> all means inform me :D
>
> Thanks for your time and help and sorry to keep bothering you.
date: Wed, 06 Aug 2008 20:46:06 +1200
author: Steve Schapel
Re: Using the SetProperty Macro action in a subform
Ok well.....
I vaguely explained it before, be it not very well. Taking the 'cost' as an
example, A previous order might have cost £30.00. So £30 is there as a guide,
and possibly it is still the same as that. Most likely it has changed though.
So the user who inputs the new information can see the text in red as a
default. Being red they can see that they may still need to change it, and
once they put a new value in (say £20.00) the text will then be shown in
black.
So changing the value changes the colour in that field.
The same thing has to apply for fields without a numerical value.
The cost control is only in the subform, the colour is not controlled by
anything external of the form.
Regarding the other thing, i dont get a errror message about black as it is
now 0, but i get the same error message but with 'Temp PO Item Query subform'
instead of 'Black'
Sorry that i am not so good at explaining things.
"Steve Schapel" wrote:
> Nick,
>
> You are not bothering me. :-)
>
> But equally, you are not helping me! :-) You're not relating to the idea
> that I'm not looking over your shoulder at your database. I need more
> information. I asked you what control you are evaluating, and where it
> is, but you didn't answer that. I am guessing you have a control on the
> main form, and you want its value to toggle the colour of the Cost
> control on the subform. But you haven't confirmed this suspicion. And
> now you are asking me to suggest a Conditional Formatting expression
> without me knowing anything about what control it is or what your
> conditions are or what kind of data it has or anything.
>
> As for the 'Black', I'm sorry I was wrong about that. I think it will
> work to use the numerical value for black, which is 0.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Access Newbie Nick wrote:
> > Ahhh ok then. So After Update would be better it seems. I tried the
> > suggestion you gave me, however the 'Black' is automatically changed to
> > '[Black]', and the message appears as follows-
> >
> > ------
> > The object doesn't contain the Automaton object 'Black'
> >
> > You tried to ru a Visual Basic procedure to set a property or method for an
> > object. However, the component doesn't make the property or method available
> > for Automation operations.
> >
> > Check the component's documentation for information on the properties and
> > methods it makes available for Automation operations.
> > ------
> >
> > Also if i could use conditional formatting that would be a lot easier
> > definately, so if you have a suggestion for an expression i can use then by
> > all means inform me :D
> >
> > Thanks for your time and help and sorry to keep bothering you.
>
date: Wed, 6 Aug 2008 02:33:00 -0700
author: Access Newbie Nick
Re: Using the SetProperty Macro action in a subform
Nick,
Aha! Now I'm starting to get it! So you want a control's colour to
change to black based on *its own* value being changed? Well, my
apologies, but I would never have guessed that from the earlier discussion.
So, if I now understand correctly, on the After Update event of the Cost
textbox, your macro will be like this:
Action: SetValue
Item: [Cost].[ForeColor]
Expression: 0
Let us know how that goes.
Prtobably jumping ahead here, but does this mean you have to also change
them all back to red again ready for the next entry?
--
Steve Schapel, Microsoft Access MVP
Access Newbie Nick wrote:
> Ok well.....
>
> I vaguely explained it before, be it not very well. Taking the 'cost' as an
> example, A previous order might have cost £30.00. So £30 is there as a guide,
> and possibly it is still the same as that. Most likely it has changed though.
> So the user who inputs the new information can see the text in red as a
> default. Being red they can see that they may still need to change it, and
> once they put a new value in (say £20.00) the text will then be shown in
> black.
>
> So changing the value changes the colour in that field.
> The same thing has to apply for fields without a numerical value.
>
> The cost control is only in the subform, the colour is not controlled by
> anything external of the form.
>
> Regarding the other thing, i dont get a errror message about black as it is
> now 0, but i get the same error message but with 'Temp PO Item Query subform'
> instead of 'Black'
>
> Sorry that i am not so good at explaining things.
date: Fri, 08 Aug 2008 09:00:13 +1200
author: Steve Schapel
Re: Using the SetProperty Macro action in a subform
Nick,
Yes, you are correct, it is a hexadecimal number, which is what has
become the standard for web site colours etc, and I suppose it is cool
that Access is using this now, *except*... I can't find an easy way to
use them in a macro. As you quite correctly point out, the SetValue and
SetProperty actions seem to still need the decimal values.
So, unless you are using colours whose value you know (like 0 for black
and 255 for red), at the moment it looks like you have to convert it,
for which you can use a converter tool such as
http://www.translatum.gr/converter/hexadecimal.htm and then use the RGB
function to get the decimal color value.
So for example, if you select a colour in an Access 2007 control that
shows you #3B8194, put that into the converter and it gives you red=59,
green=129, blue=148. So then in the Vlaue argument for the SetProperty
or SetValue action, you can put like this:
=RGB(59,129,148)
Best I can come up with so far!
--
Steve Schapel, Microsoft Access MVP
Access Newbie Nick wrote:
> the current one is base 16 i suppose?
date: Fri, 08 Aug 2008 22:33:56 +1200
author: Steve Schapel
|
|