Connecting Tech Pros Worldwide Forums | Help | Site Map

changing a control property according to record values

Francis
Guest
 
Posts: n/a
#1: Feb 2 '06
Hello i have a continuos form, and i have a command button to help
insert information on a control textbox. But when the text box is not
null, i dont want the command button to show (to the current record
only). What is the code i shall use in the Current Event of Form, in
order to display the command button for each record (for null related
text boxes).

Thanks in advance


Wayne Morgan
Guest
 
Posts: n/a
#2: Feb 2 '06

re: changing a control property according to record values


Access 2000 and newer has a Conditional Formatting option, but it doesn't
work for command buttons. While you can place code in the form's Current
event to make the button visible, the problem is that there is only one
button repeated multiple times. So, what will happen is the button will be
visible when the current record is Null, but it will be visible on all
records of the continuous form.

There are a couple of work-arounds.

1) You could place the button in the form's Header. This would give you only
one button on the form but it wouldn't scroll with the continuous part of
the form. The header part of the form will always be visible above the
detail part which is where the scroll is. You could make this button visible
or not in the form's Current event. It may work better to toggle its Enabled
property instead of its Visible property.

2) Conditional Formatting is available for textboxes. While it won't look
exactly the same, you could create a textbox that looks somewhat like a
button instead of the button. Set its Locked property to Yes and its Enabled
property to No. Use Conditional Formatting to change the Fore and Back Color
properties of the textbox to make them the same as the back color of the
form in order to hide the textbox when the associated field's value isn't
Null. Use the Click event of this textbox to run the code. The "caption" of
the textbox would be a calculated value in the Control Source (example:
="Click Me") and set the alignment property of the textbox to Centered.

--
Wayne Morgan
MS Access MVP


"Francis" <francis_1750@msn.com> wrote in message
news:1138856857.832242.62890@g44g2000cwa.googlegro ups.com...[color=blue]
> Hello i have a continuos form, and i have a command button to help
> insert information on a control textbox. But when the text box is not
> null, i dont want the command button to show (to the current record
> only). What is the code i shall use in the Current Event of Form, in
> order to display the command button for each record (for null related
> text boxes).
>
> Thanks in advance
>[/color]


Francis
Guest
 
Posts: n/a
#3: Feb 2 '06

re: changing a control property according to record values


Very Good :)

Hm that really was what i was expecting, but there has to be a way to
change a given control property in a continuos form (a bit like
condiional formating). The thing is the command button is a pop up
calendar that helps the user to insert dates, but if a date is already
inserted in the text box i dont want it to change.

Your workaround was an option, in this case i have the text box:
txtDate with conditional formating to be disabled if it's value is not
null. The problem is even if it is disabled, the commmand button cmdCal
can overrun the disable, because the command button changes the txtBox
control source programatically.

what i will try now is to insert on the Click Event of the command
button an If clause, that checks if txtDate is disabled, if this is
right it just pops up a msgbox saying u can't change txtbox value.

Francis(portugal)

Wayne Morgan
Guest
 
Posts: n/a
#4: Feb 2 '06

re: changing a control property according to record values


The comment about a textbox wasn't to disable your current textbox, it was
to use an addition textbox in lieu of the button. Another option would be to
set the DoubleClick event of your current textbox to open the calendar
instead of using a separate control for this.

--
Wayne Morgan
MS Access MVP


"Francis" <francis_1750@msn.com> wrote in message
news:1138893176.493225.69490@g49g2000cwa.googlegro ups.com...[color=blue]
> Very Good :)
>
> Hm that really was what i was expecting, but there has to be a way to
> change a given control property in a continuos form (a bit like
> condiional formating). The thing is the command button is a pop up
> calendar that helps the user to insert dates, but if a date is already
> inserted in the text box i dont want it to change.
>
> Your workaround was an option, in this case i have the text box:
> txtDate with conditional formating to be disabled if it's value is not
> null. The problem is even if it is disabled, the commmand button cmdCal
> can overrun the disable, because the command button changes the txtBox
> control source programatically.
>
> what i will try now is to insert on the Click Event of the command
> button an If clause, that checks if txtDate is disabled, if this is
> right it just pops up a msgbox saying u can't change txtbox value.[/color]


Francis
Guest
 
Posts: n/a
#5: Feb 3 '06

re: changing a control property according to record values


Thanks for your info it's working now

I just added a condition to the click event, and it won't open cal if
the value is not null. Thanks.

Closed Thread