Clearing data from a form

UsingTime
NewLounger
Posts: 16
Joined: 29 Apr 2010, 01:38

Clearing data from a form

Post by UsingTime »

I have a command button on a form to clear the data from 3 Controls in that form. 2 of the three work like a charm--the third one (CommitteeID) seems only to clear the data if I refresh, or if I even click back in that field after I have pressed the command button, it clears the data. Is there any clue why that would be, or should I just add code to refresh the form automatically?

CommitteeID is a combo box, frameRole is on option group and CommMemberName is a text box. So, the combo box is the one that doesn't clear until the form is refreshed (or I click back in that field).

Private Sub Reset_Click()
Me.CommitteeID.Value = ""
Me.frameRole.Value = ""
Me.CommMemberName.Value = ""
End Sub

Thanks for any help...

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Clearing data from a form

Post by HansV »

What happens if you set the value to Null instead of to ""?

Code: Select all

Private Sub Reset_Click()
    Me.CommitteeID.Value = Null
    Me.frameRole.Value = Null
    Me.CommMemberName.Value = Null
End Sub
Best wishes,
Hans

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Clearing data from a form

Post by JohnH »

If the name of the control does not match its control source, you see the bahaviour you describe. The underlying value in the table is set to Null (or "") but not the value on the screen.

What is the name of the combo that displays committeeID?
Regards

John

UsingTime
NewLounger
Posts: 16
Joined: 29 Apr 2010, 01:38

Re: Clearing data from a form

Post by UsingTime »

Thanks, Hans and John:
Changing to "Null" didn't seem to change the behavior any.

The name of the combo is "cbCommID"

So, changing the code as below seems to have cured the problem:

Private Sub Reset_Click()
Me.cbCommID = Null
Me.frameRole.Value = Null
Me.CommMemberName.Value = Null
End Sub

Thanks again!