Clearing a field in a form....

rnickels

Registered User.
Local time
Yesterday, 21:40
Joined
Dec 8, 2006
Messages
48
Thank you in advance:

I have a form in my Access 2007 Database.

It is a payment received form and asks the user to select a customer, declare what the payment is for, payment date etc.

One combo box in my form asks user to select how the customer is paying.

On the after update of this combo box I have an If Statement which states that if the payment type is by Credit Card then the following controls become visible on the form: NameonCreditCard, CreditCardNUmber, ExpirationDate (by default these controls are not visible).

Also in the afterupdate of the paymenttype combo box is an If Statement which states that if the payment type is by check then a control named CheckNumber becomes visible.

Now FOR MY PROBLEM:

Consider the situation:
User selects payment type as Credit Card (making the credit card controls becoming visible) and starts to enter the credit card info and then realises that actually the customer is paying by check. The user proceded to click on the payment type combo box and selects "check" making the "check number" control visible and making the credit card information controls not visible anymore.

Even though the credit card information controls are not visible anymore, the data still exists in the controls and will be entered into the PaymentTable upon saving the data in the form.

MY QUESTION: How can I clear the data in the controls that are no longer required and not visible.

Thanks again.
 
Thank you in advance:

I have a form in my Access 2007 Database.

It is a payment received form and asks the user to select a customer, declare what the payment is for, payment date etc.

One combo box in my form asks user to select how the customer is paying.

On the after update of this combo box I have an If Statement which states that if the payment type is by Credit Card then the following controls become visible on the form: NameonCreditCard, CreditCardNUmber, ExpirationDate (by default these controls are not visible).

Also in the afterupdate of the paymenttype combo box is an If Statement which states that if the payment type is by check then a control named CheckNumber becomes visible.

Now FOR MY PROBLEM:

Consider the situation:
User selects payment type as Credit Card (making the credit card controls becoming visible) and starts to enter the credit card info and then realises that actually the customer is paying by check. The user proceded to click on the payment type combo box and selects "check" making the "check number" control visible and making the credit card information controls not visible anymore.

Even though the credit card information controls are not visible anymore, the data still exists in the controls and will be entered into the PaymentTable upon saving the data in the form.

MY QUESTION: How can I clear the data in the controls that are no longer required and not visible.

Thanks again.

Hey RNickels,

One thought would be to add to your AfterUpdate event of you cboBox something like this:

If Credit Card Then
'all the controls you want visible
Me.CheckNumber = ""
Else
'all check controls visible
Me.NameonCreditCard = ""
Me.CreditCardNumber = ""
Me.ExpirationDate = ""
End if

Otherwise you could create a function that uses each controls Tag property so the form would know which controls to clear and which ones to make visible.

HTH,
Shane
 
ShaneMan

Thank you so much for your help!

Go Buck Eyes.
 

Users who are viewing this thread

Back
Top Bottom