Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Conditional Formatting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AccessNovice - 09 Mar 2006 04:17 GMT
I am creating a form where I want to conditionally format one control based
on another control.  The first control is a Yes or No question, and the other
is a "If yes, then give the date". I want the second control to be disabled
by default, unless the first control is "Yes".  I am not sure if i can do
this thru a wizard, or if I have to write a code for this.  Any suggestions
would be greatly appreciated!
Beardman - 09 Mar 2006 10:32 GMT
> I am creating a form where I want to conditionally format one control based
> on another control.  The first control is a Yes or No question, and the other
> is a "If yes, then give the date". I want the second control to be disabled
> by default, unless the first control is "Yes".  I am not sure if i can do
> this thru a wizard, or if I have to write a code for this.  Any suggestions
> would be greatly appreciated!

Exactly the same question from me.
Some VBcode has once been posted to perform the task. This code however was
nearly 2 pages long, and  included several unclarities.

It should be much more simple than that, shouldn't it?
Anyone?
Klatuu - 09 Mar 2006 15:37 GMT
Not that hard.  If you want the second control to be disabled by default, set
it's Enabled property to No in design view.  Then in the After Update event
of the first control, a Check Box, all you need is this to enable it and
populate it with the current date:

If Me.FirstControlName = True Then
   Me.SecondControlName.Enabled = True
   Me.SecondControlName = Date()
Else
   Me.SecondControlName.Enabled = False
End If

Now, as you navigate through the records in your table, this can change
based on the field your controls are bound to, so you will need the following
in the Form's Current event to keep these controls in sync with the current
record:

If Me.NewRecord Then
   Me.FirstControlName = False
   Me.SecondControlName.Enabled = False
Else
'Here is gets fuzzy, because I don't know what your business rules are.  It
will depend on whether you only want to allow the date to be entered for new
records or not and whether your first control is bound to a field in the
table.  If you need more assistance, post back with the business rules.

   If Me.FirstControl = True Then
       Me.SecondControl.Enabled = True

> I am creating a form where I want to conditionally format one control based
> on another control.  The first control is a Yes or No question, and the other
> is a "If yes, then give the date". I want the second control to be disabled
> by default, unless the first control is "Yes".  I am not sure if i can do
> this thru a wizard, or if I have to write a code for this.  Any suggestions
> would be greatly appreciated!
John Spencer - 09 Mar 2006 16:41 GMT
If you are using Access 2000 or greater, you should be able to do this using
the conditional formatting.  This assumes that you have the yes or no
question and the If Yes, give date field in the same record.

In design view, click on the field you want to enable/disable
Select Conditional formatting from the Format menu
Change Condition 1 from "Field value is" to "Expression is"
In the box that appears enter criteria YesNoField = False
Click the Enabled button (last button in row of icons) so it disables the
control
Click OK

Test that and see if it works
>I am creating a form where I want to conditionally format one control based
> on another control.  The first control is a Yes or No question, and the
[quoted text clipped - 5 lines]
> suggestions
> would be greatly appreciated!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.