PC Review


Reply
Thread Tools Rate Thread

Validating a field value based on another field.

 
 
Gina
Guest
Posts: n/a
 
      16th Apr 2004
Hi!

I have a form called frmMatlDetail, with a subform on it
called frmMatlActivity (the subform is based on a query
called qryMatlActivityForm). On the subform I have a
field called Activity (which can have a value of P, A, U,
R, or ADJ) and a field called Qty.
If a user enters P in the Activity field, I want to be
sure that the Qty field remains Null.
If a user enters A or U in the Activity field, the Qty
field must be a negative number.

Is there a way to do this with a macro or code?

Thanks so much.

 
Reply With Quote
 
 
 
 
Graham R Seach
Guest
Posts: n/a
 
      16th Apr 2004
Gina,

On the subform, do the following:

1. Create the following procedure in the form's class module:
Public Function CheckQty()
Select Case Me.Activity
Case "P"
Me.Qty = Null
Case "A", "U"
If Me.Qty > 0 Then
DoCmd.Beep
MsgBox "Qty must be negative!"
Me.Qty = ""
End If
Case Else
'Do whatever...
End Select
End Function

2. In Activity's AfterUpdate property (the property - not the event
procedure), add the following code:
=CheckQty()

3. In Qty's AfterUpdateEvent, add the following code
=CheckQty()

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Gina" <(E-Mail Removed)> wrote in message
news:1d39801c42342$944cc790$(E-Mail Removed)...
> Hi!
>
> I have a form called frmMatlDetail, with a subform on it
> called frmMatlActivity (the subform is based on a query
> called qryMatlActivityForm). On the subform I have a
> field called Activity (which can have a value of P, A, U,
> R, or ADJ) and a field called Qty.
> If a user enters P in the Activity field, I want to be
> sure that the Qty field remains Null.
> If a user enters A or U in the Activity field, the Qty
> field must be a negative number.
>
> Is there a way to do this with a macro or code?
>
> Thanks so much.
>



 
Reply With Quote
 
 
 
 
Gina
Guest
Posts: n/a
 
      16th Apr 2004
Thanks so much...works great!

Gina


>-----Original Message-----
>Gina,
>
>On the subform, do the following:
>
>1. Create the following procedure in the form's class

module:
> Public Function CheckQty()
> Select Case Me.Activity
> Case "P"
> Me.Qty = Null
> Case "A", "U"
> If Me.Qty > 0 Then
> DoCmd.Beep
> MsgBox "Qty must be negative!"
> Me.Qty = ""
> End If
> Case Else
> 'Do whatever...
> End Select
> End Function
>
>2. In Activity's AfterUpdate property (the property - not

the event
>procedure), add the following code:
> =CheckQty()
>
>3. In Qty's AfterUpdateEvent, add the following code
> =CheckQty()
>
>Regards,
>Graham R Seach
>Microsoft Access MVP
>Sydney, Australia
>
>Microsoft Access 2003 VBA Programmer's Reference
>http://www.wiley.com/WileyCDA/WileyTitle/productCd-

0764559036.html
>
>
>"Gina" <(E-Mail Removed)> wrote in

message
>news:1d39801c42342$944cc790$(E-Mail Removed)...
>> Hi!
>>
>> I have a form called frmMatlDetail, with a subform on it
>> called frmMatlActivity (the subform is based on a query
>> called qryMatlActivityForm). On the subform I have a
>> field called Activity (which can have a value of P, A,

U,
>> R, or ADJ) and a field called Qty.
>> If a user enters P in the Activity field, I want to be
>> sure that the Qty field remains Null.
>> If a user enters A or U in the Activity field, the Qty
>> field must be a negative number.
>>
>> Is there a way to do this with a macro or code?
>>
>> Thanks so much.
>>

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
digital signature not validating in outlook, but validating everyw =?Utf-8?B?UmFsZiBIYXVzZXI=?= Microsoft Outlook Discussion 10 10th Jul 2006 09:49 AM
Calculating a date field based on another field's date, based on another fields value circuit slave Microsoft Access Forms 6 26th Jan 2006 06:42 AM
Validating a field based on value of another field Emmanuel Microsoft ASP .NET 1 22nd Nov 2005 01:35 PM
validating datagridtextboxcolumn textbox, validating event fire twice, why? SMai24@gmail.com Microsoft Dot NET Framework Forms 0 27th Sep 2005 08:06 PM
validating datagridtextboxcolumn textbox, validating event fire twice, why? SMai24@gmail.com Microsoft C# .NET 0 27th Sep 2005 08:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 PM.