If statement help

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Access 2000. I have a texbox of [Fee] which shows the fee for a product.
The next textbox is [FeeCode] which a code is entered depending on the type
of fee. Occasionaly the data entry user will forget to enter the feecode.
I need a way to prevent an entry from being omitted if there is a fee. It
is not a problem if there is no fee in the fee field. Only if there is a
fee is when I must have a code entered in the fee code field. Any ideas.
Thanks
 
Randy

In the form's BeforeUpdate event, add code that inspects the [Fee] control.
If it has a non-zero value, have the code inspect the [FeeCode] control,
confirming whether/if it has a value.

If no, use a messagebox to inform the user and use Cancel = True to cancel
the update (i.e., don't save the data).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I'm sorry, I'm very much a beginner. Can you give me an actual example of
the code?..Thanks

Jeff Boyce said:
Randy

In the form's BeforeUpdate event, add code that inspects the [Fee]
control. If it has a non-zero value, have the code inspect the [FeeCode]
control, confirming whether/if it has a value.

If no, use a messagebox to inform the user and use Cancel = True to cancel
the update (i.e., don't save the data).

Regards

Jeff Boyce
Microsoft Office/Access MVP


Randy said:
Access 2000. I have a texbox of [Fee] which shows the fee for a product.
The next textbox is [FeeCode] which a code is entered depending on the
type of fee. Occasionaly the data entry user will forget to enter the
feecode. I need a way to prevent an entry from being omitted if there is
a fee. It is not a problem if there is no fee in the fee field. Only if
there is a fee is when I must have a code entered in the fee code field.
Any ideas. Thanks
 
Randy

This isn't a class assignment, is it?!

If Me.Fee > 0 Then
If Nz(Me.FeeCode,"") = "" Then
MsgBox "I need a Fee Code", vbOKOnly,"Cancelling..."
Cancel = True
End If
End If

Regards

Jeff Boyce
Microsoft Office/Access MVP

Randy said:
I'm sorry, I'm very much a beginner. Can you give me an actual example of
the code?..Thanks

Jeff Boyce said:
Randy

In the form's BeforeUpdate event, add code that inspects the [Fee]
control. If it has a non-zero value, have the code inspect the [FeeCode]
control, confirming whether/if it has a value.

If no, use a messagebox to inform the user and use Cancel = True to
cancel the update (i.e., don't save the data).

Regards

Jeff Boyce
Microsoft Office/Access MVP


Randy said:
Access 2000. I have a texbox of [Fee] which shows the fee for a
product. The next textbox is [FeeCode] which a code is entered depending
on the type of fee. Occasionaly the data entry user will forget to
enter the feecode. I need a way to prevent an entry from being omitted
if there is a fee. It is not a problem if there is no fee in the fee
field. Only if there is a fee is when I must have a code entered in the
fee code field. Any ideas. Thanks
 
Back
Top