Unable to save record on close

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

Guest

Hi there!

I have a form that, depending on various options selected, has subforms pop
open. These pop up forms are used to specify details for the current record
on the main form.

When I am done filling in any one of the particular pop up forms, I close it
and return to the main form. All is fine and good unless I go to close the
main form before moving to another main form record. If I try to close the
main form at before moving to a new record I get the warning message "You
can't save this record at this time."

Is there something I can do that actually creates the record before I move
to a new record?
 
One popular method is this:
If Me.Dirty=True then Me.Dirty=False
You speak of both subforms and pop-up forms; these are two very different
things.
Which are you using?
 
Hi,

I'm using a pop-up form.

I placed the code you provided after the select statements that open the
pop-up form and when I select the form I want to open (from a drop down list)
The pop-up form opens and I get the error "Run-time error '2101': The
setting you entered isn't valid for this property." When I go to debug the
error is on the Me.Dirty = False statement.

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)

Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""
Case 5 'Evaluations
DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , , acFormAdd, ,
MyOpenArgs
Case 7 'Contract Options
DoCmd.GoToControl "Frame_Contract_Type"
Case 8 'Rentals
DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, , MyOpenArgs
Case 12 'debit memos
DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, , MyOpenArgs
Case Else 'go to comments
DoCmd.GoToControl "Comments"
End Select

If Me.Dirty = True Then
Me.Dirty = False
End If

End Sub

Any suggestions?
 
Actually, let me revise my last statement. For Case 5, I need the record in
the main form to save before the pop-up form opens. Still getting the error.

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)

Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""
Case 5 'Evaluations
If Me.Dirty = True Then
Me.Dirty = False
End If

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , , acFormAdd, ,
MyOpenArgs
Case 7 'Contract Options
DoCmd.GoToControl "Frame_Contract_Type"
Case 8 'Rentals
DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, , MyOpenArgs
Case 12 'debit memos
DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, , MyOpenArgs
Case Else 'go to comments
DoCmd.GoToControl "Comments"
End Select

End Sub
 
Well, you certainly need to save the current record (that's what the code I
posted should do) *before* you open the pop-up form.
Here's a different line of code you could try:
DoCmd.RunCommand acCmdSaveRecord

BTW, is the form where you are making your selections (the form with the
combobox Job_Type) the same as your main form?
 
Actually, I just figured this one out. The Me.Dirty did not work and neither
did the docmd.runcommand asCmdSaveRecord. I finally put a Me.Refresh after
each of the cases that was opening a new form in my select case statement.
 
Back
Top