S
Stuck with Excel
I have a database which has mutliple forms.
The main form (search parameters) creates a recordset using SQL to return
the results in a ListBox. When I click on a desired record on the results it
opens another form.
The problem I have is that I am using the dirty property to search for
changes on the form and if there are changes to save and close the form.
Code as follows:
Private Sub cmbclose_Click()
On Error GoTo Err_cmbClose_Click
If Form_frmMaintainProject.Dirty = True Then
If MsgBox("This record has been changed, do you want to save changes
and close?", vbYesNo) = vbYes Then
Call txtNowStamp_Change
Call TxtNameStamp_Change
ElseIf vbNo Then
Exit Sub
End If
DoCmd.Close
ElseIf Form_frmMaintainProject.Dirty = False Then
DoCmd.Close
End If
Exit_cmbClose_Click:
Exit Sub
Err_cmbClose_Click:
MsgBox Err.Description
Resume Exit_cmbClose_Click
End Sub
The problem I have is that when I run the above the form switches focus to
the search form and I have to click the close button to save the record and
close the form. This only happens when the Dirty = True. When Dirty = False
i.e. no changes the form closes fine as it just works of a docmd.close. I
think that the fact that the recordset is bound to the search form and not
the details form is where my problem lies. Is there a way I can get this to
run without switching the form focus back to the search parm form?
This is on Access 97 (back in the stone age which is not helping)
The main form (search parameters) creates a recordset using SQL to return
the results in a ListBox. When I click on a desired record on the results it
opens another form.
The problem I have is that I am using the dirty property to search for
changes on the form and if there are changes to save and close the form.
Code as follows:
Private Sub cmbclose_Click()
On Error GoTo Err_cmbClose_Click
If Form_frmMaintainProject.Dirty = True Then
If MsgBox("This record has been changed, do you want to save changes
and close?", vbYesNo) = vbYes Then
Call txtNowStamp_Change
Call TxtNameStamp_Change
ElseIf vbNo Then
Exit Sub
End If
DoCmd.Close
ElseIf Form_frmMaintainProject.Dirty = False Then
DoCmd.Close
End If
Exit_cmbClose_Click:
Exit Sub
Err_cmbClose_Click:
MsgBox Err.Description
Resume Exit_cmbClose_Click
End Sub
The problem I have is that when I run the above the form switches focus to
the search form and I have to click the close button to save the record and
close the form. This only happens when the Dirty = True. When Dirty = False
i.e. no changes the form closes fine as it just works of a docmd.close. I
think that the fact that the recordset is bound to the search form and not
the details form is where my problem lies. Is there a way I can get this to
run without switching the form focus back to the search parm form?
This is on Access 97 (back in the stone age which is not helping)