How to clear inputs in a data-entry subform?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,
I have a subform sfReidProductDrawings_DataEntry in a form frmAddNewDrawing.
I use a command button in the form intended to clear all inputs in the
subform first (because if the primary key field isn't filled with some value,
Access won't let me close the form, and also this can prevent unfinished
inputs from being saved when user decides to discontinue with data entry
during half way) before close the form and open another form
frmReidProductDrawings. But there seems to be something wrong with the
"dirty" and "undo" function -- compile error "Method or data member not
found" appears. How do I fix this? Many thanks

--- start of code ---
Private Sub cbReturnToDWGSearch_Click()
' Clear all fields entered in sfReidProductDrawings_DateEntry
If Me.sfReidProductDrawings_DataEntry.Dirty Then
Me.sfReidProductDrawings_DataEntry.Undo
End If
DoCmd.Close acForm, Me.sfReidProductDrawings_DataEntry.Name
' Close frmAddNewDrawing
DoCmd.Close acForm, "frmAddNewDrawing", acSaveYes
' Open frmReidProductDrawings
DoCmd.OpenForm "frmReidProductDrawings"
' Maximize the form
DoCmd.Maximize
End Sub
--- end of code ---
 
As you move off the subform to the button on the main form, the record is
saved. Thus it is no longer dirty. You can use a continuous subform and put
a button on each row. You can also delete the subform record from the main
form. Probably the most elegant method is to use the BeforeUpdate event of
the Form property of the subform to conditionally Undo the record.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top