Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to clear a field upon entry to another? 1

Status
Not open for further replies.

rlh777

Technical User
Oct 14, 2002
36
US
I have a combo box with three choices and a field that is set to read the date. I would like to have the date clear when one of the choices is selected. Any thoughts?
 
if on a form...


then


me.date_field_name = null
 
Ooops...I forgot, place that code in the "event" propertie of the "combo object" that you would like to trigger the executituon of the code
 
I'm not for certain if I completely understand. My combo box, "CustomerType" has 4 choices; Existing, Potential, Lost, Unable To Help. The second field is the "CustomerPurchaseDate". The Customer in my system could possibly be, "Existing" with a purchase date of "01/01/2003". I would like the date to be removed if the "CustomerType" of Lost is selected. I understand event procedures, but I'm not for certain which event. Could you explain a little further?
 
In the AfterUpdate event of CustomerType:

If Me!CustomerType = "Lost" Then
Me!CustomerPurchaseDate = Null
End If
 
That worked great! Now another...Now I have two check boxes. They read: "Quote Won" "Quote Lost". There are a few fields that go along with them. They are: "Percentage Chance To Gain Sale" "Proposed Win Date" "Proposed Won Amount" & "Annual Support Generated". I would like to be able to Check the box, "Quote Won" and have the "Percentage Chance To Gain Sale to read 100% and the "Proposed Win Date" to change to the current date. If the "Quote Lost" box is checked, I would like the "Percentage Chance To Gain Sale" to read 0%, the "Proposed Date To Gain Sale" to erase, and the "Proposed Won Amount" and the "Annual Support Generated" fields to go to $0.00. HELP!
 
Use this as a guide:

Private Sub QuoteWon_AfterUpdate()
If Me!QuoteWon = True Then
Me!QuoteLost = False
Me!PercentageChanceToGainSale = 1 'if control not formatted as % use 100
Me!ProposedWinDate = Date
Else
Me!QuoteLost = True
Me!PercentageChanceToGainSale = 0
Me!ProposedWinDate = Null
Me!ProposedWonAmount = 0
Me!AnnualSupportGenerated = 0
End If
End Sub

Private Sub QuoteLost_AfterUpdate()
If Me!QuoteLost = True Then
Me!QuoteWon = False
Me!PercentageChanceToGainSale = 0
Me!ProposedWinDate = Null
Me!ProposedWonAmount = 0
Me!AnnualSupportGenerated = 0
Else
Me!QuoteWon = True
Me!PercentageChanceToGainSale = 1 'if control not formatted as % use 100
Me!ProposedWinDate = Date
End If
End Sub

Notice, I have taken the spaces out of the control names, I think you should do the same. It makes it easier to reference them.

Good Luck


 
Thanks so much! I do have my control names without spaces. I failed to report that to you...sorry. One more thing....How would I alter the above thread. The one pertaining to the "LostCustomer" to give me a message box that says: "Changing The Customer Type To "Lost" Will Remove The Purchase Date. Continue?" If yes, is checked, then proceed with the above thread and if not...leave as is.
 
This should work ok for you.

Private Sub QuoteWon_AfterUpdate()
Dim Response
If Me!QuoteWon = True Then
Me!QuoteLost = False
Me!PercentageChanceToGainSale = 1 'if control not formatted as % use 100
Me!ProposedWinDate = date
Else
Response = MsgBox("Changing The Customer Type To 'Lost' Will Remove The Purchase Date. Continue?", vbYesNo, "Quote Lost")
If Response = vbNo Then
Me!QuoteWon = True
Exit Sub
End If
Me!QuoteLost = True
Me!PercentageChanceToGainSale = 0
Me!ProposedWinDate = Null
Me!ProposedWonAmount = 0
Me!AnnualSupportGenerated = 0
End If
End Sub

Private Sub QuoteLost_AfterUpdate()
Dim Response
If Me!QuoteLost = True Then
Response = MsgBox("Changing The Customer Type To 'Lost' Will Remove The Purchase Date. Continue?", vbYesNo, "Quote Lost")
If Response = vbNo Then
Me!QuoteLost = False
Exit Sub
End If
Me!QuoteWon = False
Me!PercentageChanceToGainSale = 0
Me!ProposedWinDate = Null
Me!ProposedWonAmount = 0
Me!AnnualSupportGenerated = 0
Else
Me!QuoteWon = True
Me!PercentageChanceToGainSale = 1 'if control not formatted as % use 100
Me!ProposedWinDate = date
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top