A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Required Field Conditional



 
 
Thread Tools Display Modes
  #1  
Old August 31st, 2004, 07:52 PM
Katherine R
external usenet poster
 
Posts: n/a
Default Required Field Conditional

How would I make a required field conditional? Field 1 is a data type
Yes/No. I would like entry into Field 2 to be required if Field 1 is Yes.
Can this be set in the table or would it need to be set in the form?
  #2  
Old September 1st, 2004, 05:48 AM
fredg
external usenet poster
 
Posts: n/a
Default

On Tue, 31 Aug 2004 11:52:54 -0700, Katherine R wrote:

How would I make a required field conditional? Field 1 is a data type
Yes/No. I would like entry into Field 2 to be required if Field 1 is Yes.
Can this be set in the table or would it need to be set in the form?


You can code the Form's BeforeUpdate event to see if the check box has
been checked and a Value entered in Field2, and not allow the form to
be saved.

If Me![Field1]=True and IsNull(Me![field2]) Then
MsgBox "You must enter a value in Field2."
Cancel = True
[Field2].SetFocus
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
  #3  
Old September 1st, 2004, 05:52 AM
Raghu Prakash
external usenet poster
 
Posts: n/a
Default

Hi Katherine,

Apply or change conditional formatting on a control

On a form or report:-
Open the form in Design view (Design view: A window that shows the design
of these database objects: tables, queries, forms, reports, macros, and
data access pages. In Design view, you can create new database objects and
modify the design of existing ones.) or Form view (Form view: A window that
displays a form to show or accept data. Form view is the primary means of
adding and modifying data in tables. You can also change the design of a
form in this view.), or the report in Design view.
Do one of the following:
If you are in Design view, click the control for which you want to apply
conditional formatting.
If you are in Form view, make sure the control has focus (focus: The
ability to receive user input through mouse or keyboard actions or the
SetFocus method. Focus can be set by the user or by the application. The
object that has focus is usually indicated by a highlighted caption or
title bar.).
On the Format menu, click Conditional Formatting.
Do one or more of the following:
Change the format of a control based on a value or expression

Do one of the following:

Base conditional formatting on the value of the control
The control's appearance changes if the value in the underlying field for
that record meets criteria that you specify. For example, you can specify
the UnitPrice field to be highlighted with a different color when it
contains a value between $25.00 and $50.00. Also, you can specify an
additional criteria to highlight the UnitPrice field with another color if
it contains a value greater than $50.00.

To use values in the selected control as the formatting criteria, under
Condition 1, click Field Value Is in the first box, click the comparison
phrase in the second box, and then type a value in the third (and fourth)
box. You can enter a constant value or an expression.

Base conditional formatting on an expression
You can also change the appearance of a control when an expression or a
Visual Basic® for Applications (VBA) function returns a value of TRUE. For
example, you might want the appearance of the ProductName field to match
the appearance of the UnitPrice field. To change the format of the
ProductName field to match the format of the UnitPrice field, use
expressions in the conditional formatting criteria for the ProductName
field that check the value of the UnitPrice field.

To use an expression as the formatting criteria (to evaluate data or a
condition other than the values in selected controls), click Expression Is
in the first box, and then enter the expression in the second box. The
expression must return a logical value of TRUE or FALSE.


Select the font style, color, or other formatting that you want to apply.
Microsoft Access applies the selected formatting only if the control value
meets the condition, or the expression returns a value of TRUE.
Tip

You can use conditional formatting to prevent users from making changes to
a control, when a condition is true. Specify the criterion, and in the
format section, click the Enabled button (the rightmost button in the
Conditional Formatting dialog box) once.
To add another condition, click Add, and then repeat steps 1 and 2.
Change the format of the control that has focus in a form

You can make data entry easier by using conditional formatting to highlight
the control that has the focus. When the control you're located in is
highlighted, it's easier to work with a form that contains many controls,
or with a continuous form or a datasheet form that contains many records.

In the Condition x area of the Conditional Formatting dialog box, click
Field Has Focus in the first box.
Select the font style, color, or other formatting that you want the field
to have when it has focus.
Note The procedure described above will highlight the specific control
when it gets focus. When focus changes, the control that gets the focus
will not appear highlighted unless you repeat the above two steps for that
control. To apply conditional formatting to multiple controls, select them
before you click Conditional Formatting on the Format menu, and then
specify the criteria and format.

Change, add, or remove a condition

To change an existing condition, change the criterion, or the current
format settings.
To add a new condition, click Add.
To remove one or more conditions, click Delete, and then select the check
box for the condition or conditions you want to delete.
Click OK.

Notes

When you open the Conditional Formatting dialog box, it displays the
current default formatting for the selected control, including colors, font
styles, and any expressions that you may have defined for the field.

You can specify up to three conditions for each control.

Conditional formatting is not preserved when you output or export (export:
To output data and database objects to another database, spreadsheet, or
file format so another database or program can use the data or database
objects. You can export data to a variety of supported databases, programs,
and file formats.) a form or a report to another file format.

If none of the specified conditions are true, the control keeps its
existing formatting. If more than one specified condition is true, Access
applies only the formatting of the first true condition.

On a data access page:-
In a data access page, you can apply conditional formatting to a control
programmatically. You can change the format of data based on one or more
criteria, or change the formatting of the control that has focus.

The following illustration shows a data access page, where a record is
displayed in red if the # In Stock field has a value that is less than or
equal to 20.

Open a data access page in Design view.
Do one of the following:
On an ungrouped page where the size of the data page is set to 1, add code
to the Current event to apply conditional formatting to the controls on the
page.
On all other pages, add code to the DataPageComplete event to apply
conditional formatting to the controls on the page.


For Further Information:
http://office.microsoft.com/en-us/as...691661033.aspx

Please let me know has this helped You...
Thank you...
Raghu...
This posting is provided "AS IS" with no warranties, and confers no rights.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update a field with data from another field kboy Running & Setting Up Queries 3 July 30th, 2004 07:51 PM
Field list greyed out when trying to add an option group Tony Using Forms 1 July 1st, 2004 03:40 AM
Bug? - Group By turning field property from Memo to Text Callaway Running & Setting Up Queries 3 June 28th, 2004 04:37 AM
lookup field rvmom New Users 2 May 23rd, 2004 03:06 AM


All times are GMT +1. The time now is 12:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.