Save to Database

  • Thread starter Thread starter dkuntz
  • Start date Start date
D

dkuntz

Guest
I have a Form that will primarily be used as a Data Entry Form. I want to have a "Submit" button that can be clicked to send the data that they entered to the database and clear the Form. As it is now the only way all of the data is cleared and sent to the databse is if they tab through the whole Form. The code below doesn't seem to be doing the trick.

Any help would be appreciated!!

Private Sub cmdSubmit_Click()

Dim ctl As Control
Dim tbx As TextBox
On Error GoTo Err_cmdSubmit_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


For Each ctl In Me.Controls
If ctl Is tbx Then
tbx.Text = ""
End If
Next ctl

Exit_cmdSubmit_Click:
Exit Sub

Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click

End Sub
 
Assuming the form is bound to a table (or query) try:
Code:
DoCmd.GoToRecord , , acNewRec
That should move to a new, blank record and automatically sabve the one you were working on.
 
That did it,

Thank you!!
 
Glad it worked for you!

Too bad I can't type: what does "sabve" mean, anyway? :D
 

Users who are viewing this thread

Back
Top Bottom