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

Form problem using vba

Status
Not open for further replies.

mychalB

Programmer
Feb 8, 2002
7
US
Hello All,

Im pretty new to programming. I have a project using an access DB using forms generated with VBA. I ran into a problem that seems simple but I cant figure it out. What I am trying to do is add a record to the DB. Process that I am using to clear my controls is this

Private Sub ctrlClear()
Dim objctrl As Control

For Each objctrl In Me.Controls
If TypeOf objctrl Is TextBox Then
objctrl.SetFocus
objctrl.Text = ""
ElseIf TypeOf objctrl Is ComboBox Then
objctrl.SetFocus
objctrl.Text = ""
End If
Next objctrl

End Sub

it clears the controls but it also deletes the fields associated to the record I had just cleared in the DB.

I dont know what other information you may need. Im using the DAO 3.6 object library.

thanks in advance
Mychal
 
If I understand you correctly you have either entered some data as a new record and then ran the procedure to clear the fields for fresh input. Or You are clearing the fields prior to entering a fresh record.

Either way if you have a record on view and you ran that procedure the underlying table record would have all its values set to zero length string.

If you just want to clear the current form ready to accept a new record then use:

DoCmd.GoToRecord , , acNewRec

The command button wizard will create a button to do this.

Regards
Rod.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top