Save Record Command Not Clear Form For New Record

  • Thread starter Betty via AccessMonster.com
  • Start date
B

Betty via AccessMonster.com

The following is my code in a standard module to save data entry records. It
saves to the table but does not clear the form to add an additional new
record: The query saves the subform records.

Public Function AddRcd_Click()
Dim JobOrder As Long
Dim frmActive As Form
Set frmActive = Screen.ActiveForm

On Error GoTo Err_AddRcd_Click
If (IsNull([JobOrder])) Then
' If no Job Order selected, stop procedure
MsgBox "You Must Enter A Job Order#"
Cancel = True
Exit Function
Else

DoCmd.OpenQuery "qryAppendToEvent"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
End If

Exit_AddRcd_Click:
Exit Function

Err_AddRcd_Click:
MsgBox "Error While Trying To Add Record"
Resume Exit_AddRcd_Click

End Function


Thanks,
Betty
 
G

Guest

It appears you are using an unbound form ...
You need to reintialize the controls ...
Try "calling" this subroutine after you have execited the append query.

Public Sub InitializeControls(ByVal frm As Form)
Dim ctl As Control

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acCheckBox, acOptionButton
ctl = False
Case acComboBox, acListBox, acTextBox
ctl = Null
End Select
Next

End Sub

R. Hicks
 

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