After SaveRecord, how to clear textboxes for next entry?

H

Harold A. Mackey

Upon clicking a 'Save Record' button, I want all textboxes in a form to be
blank, and the form ready for the input of another record.

Any links to a VBA language specs would be greatly appreciated.

thanks
Harry
 
B

Brendan Reynolds

If it's a bound form, all you need is ...

DoCmd.GoToRecord , , acNewRec

If it's unbound, you'll need to loop the Controls collection and set the
appropriate controls to Null. In the example below, I've used the Tag
property to determine which controls should be cleared (so that the code
doesn't try to do things like referring to the Value property of a command
button, which would raise an error because a command button doesn't have a
value property).

Private Sub Command6_Click()

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "ClearMe" Then
ctl.Value = Null
End If
Next ctl

End Sub

There's a VBA language reference in the help files, or online at
http://msdn.microsoft.com/library. In the menu on the left of the page look
for 'Office Solutions Development', then 'Office 2003' then 'VBA Language
Reference'.
 
Top