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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearing an unbound form

Status
Not open for further replies.

jalgier

Programmer
Nov 7, 2001
15
US
Greetings,

I would like to clear all fields on an unbound form I am creating. The form is used to enter a record (via a submit button with ADO code behind it). I would like to add a 'Clear' form button to allow the user to clear all values in the fields. I have tried the following to no avail.
Private sub Clear_click()
Me.Undo
End Sub

The form has a variety of objects (subform, text boxes, combo boxes, and check boxes). Any suggestions besides setting all values to 'null' in the code (there are a lot of fields)? Thanks in advance
 
I am not sure what you want but here is a copy and paste from MSAccess97 help.... You probably don't need to check to see if its a "acTextBox" but this should give you some ideas. At the "with ctl" section just replace it with what you want the controls to show

Sub SetTextBoxProperties(frm As Form)
Dim ctl As Control

' Enumerate Controls collection.
For Each ctl In frm.Controls
' Check to see if control is text box.
If ctl.ControlType = acTextBox Then
' Set control properties.
With ctl
.SetFocus
.Enabled = True
.Height = 400
.SpecialEffect = 0
End With
End If
Next ctl
End Sub
 
Excellent. I think this will give me the direction I was looking for. Thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top