Clear contents of an unbound text box on a bound form.

D

Dave K.

I would like to clear the contents of an unbound text box in access 2003. I
have several unbound text boxes that I enter numbers and then press a command
button that runs a macro to add them up and enter the total into a bound
field (like a calculator). I also have a command button that goes to a new
record. I need to clear the contents of the unbound boxes when I goto the
new record.
 
R

RonaldoOneNil

Do you mean a new record or a different record or both ?

In the On Current event of the form you can put this code

Me.TextBox1 = ""
Me.TextBox2 = ""
etc.

if you only want to clear thjem on a new record then put an if around the
lines

If Me.NewRecord = True Then
Me.TextBox1 = ""
Me.TextBox2 = ""
etc.
End If
 
D

Dave K.

Thanks I actual just just put in the command button for a new record and It
works fine.

Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click


DoCmd.GoToRecord , , acNewRec
Me.Check1 = 0
Me.Check2 = 0
Me.Check3 = 0
Me.Check4 = 0
Me.Check5 = 0
DoCmd.GoToControl "date"

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top