Clear data from fields when listbox selection changed

dbDamo

Registered User.
Local time
Today, 13:44
Joined
May 15, 2009
Messages
395
Hi

I have a listbox with 5 options and 5 controls which are enabled/disabled based on the selection from this listbox.

What I need to do is clear any data entered into the 5 controls for a record each time the selection from the listbox is changed. Sounds simple, but I am having difficulty in deciding where to place the code.

I've thought about placing it in the On Change event of the list box but wasn't sure if the undo action would undo the clearing of the controls, in case a user accidentally changes the selection?

While I am clearing the data from the controls, I do not want to lose the information, so I am hoping to capture the changing/clearing of data with my existing audit trail which captures the name of the control that was changed, before and after values of the control and the name of the user who made the change.

As long as I can capture the changing/clearing with my audit trail I'm not so bothered about the undo action as I can tell the user to track the changes made to re-enter the data - but obviously this is not ideal.

Thanks in advance for any help and guidance.
 
All sorted. Went with the On Change event, called a message asking the user if they were sure they waned to change the selection, if they said yes the controls were cleared, if they said no i undid their selection. Also managed to modify my audit module to add null value field changes. 3 hours well spent!
 
At the same junction point with the same idea.
It would have been helpful to see the code posted.
 
I placed this code in the On Change event:-

Code:
Dim Msg As String
Dim Style As vbMsgBoxStyle
Dim Title As String
Dim Response As vbMsgBoxResult
 
Msg = "Your Question Here"
Style = vbYesNo
Title = "Your Title Here"
Response = MsgBox(Msg, Style,Title)
 
If Response = vbYes Then
Me.Your1stControlToClearHere = Null
Me.Your2ndControlToClearHere = Null
'etc etc
Else
Me.Undo
End If
 
  • Like
Reactions: Rx_

Users who are viewing this thread

Back
Top Bottom