A
Antonio via AccessMonster.com
Hi,
I have one main form, which is based in a table called Employee
I have sub form #1 which shows records from a table called
EmployeeCompensation
I have sub form #2 which is an exact copy of #1, but for temporary purposes.
The objective of these 2 sub-forms is that #1 contains the actual Employee
Compensation and #2 will serve as a Revision, for each employee.
So I have a “Revise” Button on #1, whenever I click it, an exact record is
copied from #1 to a temp Table called EmployeeCompensationTemp, and Sub Form
#2 appears
I have a button in #2 which will allow me to Delete the current revision,
case it exists.
Problem:
When I click Delete Revision the following code is run:
Dim RevisionProposedRcdst As Recordset
Set RevisionProposedRcdst = CurrentDb.OpenRecordset("SELECT * FROM
EmployeesCompensationTemp WHERE EmployeesCompensationTemp.EmployeeID=" &
[Forms]![EmployeeRevision]![EmployeeRevisionDetail].[Form]![EmployeeID] & ";")
If Not RevisionProposedRcdst.EOF Then
If MsgBox("DATA WILL BE LOST. Are you sure you want to delete this
Revision?", vbYesNo + vbCritical) = vbYes Then
RevisionProposedRcdst.Delete
RevisionProposedRcdst.Close
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Form.
Requery 'HERE's the ERROR
End If
Else
MsgBox "There is no open Revision for this Employee", vbExclamation
End If
The line commented as "'HERE's the ERROR" is the one that is giving me
headaches…
The whole idea is only to show the Sub Form #2 if in fact there are Open
Revisions, else, hide it.
For that I wrote this event:
‘-------------------------------------------------------------------
Private Sub Form_Current()
Dim TempRcdst As Recordset
Forms![EmployeeRevision]![EmployeeRevisionDetail].SetFocus ‘This is Sub Form
#1
Set TempRcdst = CurrentDb.OpenRecordset("SELECT * FROM
EmployeesCompensationTemp WHERE EmployeesCompensationTemp.EmployeeID=" &
[Forms]![EmployeeRevision]![EmployeeRevisionDetail].[Form]![EmployeeID] & ";")
If TempRcdst.EOF = True Then
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Visible =
False
Else
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Visible = True
End If
TempRcdst.Close
End Sub
‘-------------------------------------------------------------------------
The problem is, Access breaks in line Forms![EmployeeRevision]!
[EmployeeRevisionProposedDetail].Form.Requery and says:
“Record Has Been Deleted”
Any clue?
I have one main form, which is based in a table called Employee
I have sub form #1 which shows records from a table called
EmployeeCompensation
I have sub form #2 which is an exact copy of #1, but for temporary purposes.
The objective of these 2 sub-forms is that #1 contains the actual Employee
Compensation and #2 will serve as a Revision, for each employee.
So I have a “Revise” Button on #1, whenever I click it, an exact record is
copied from #1 to a temp Table called EmployeeCompensationTemp, and Sub Form
#2 appears
I have a button in #2 which will allow me to Delete the current revision,
case it exists.
Problem:
When I click Delete Revision the following code is run:
Dim RevisionProposedRcdst As Recordset
Set RevisionProposedRcdst = CurrentDb.OpenRecordset("SELECT * FROM
EmployeesCompensationTemp WHERE EmployeesCompensationTemp.EmployeeID=" &
[Forms]![EmployeeRevision]![EmployeeRevisionDetail].[Form]![EmployeeID] & ";")
If Not RevisionProposedRcdst.EOF Then
If MsgBox("DATA WILL BE LOST. Are you sure you want to delete this
Revision?", vbYesNo + vbCritical) = vbYes Then
RevisionProposedRcdst.Delete
RevisionProposedRcdst.Close
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Form.
Requery 'HERE's the ERROR
End If
Else
MsgBox "There is no open Revision for this Employee", vbExclamation
End If
The line commented as "'HERE's the ERROR" is the one that is giving me
headaches…
The whole idea is only to show the Sub Form #2 if in fact there are Open
Revisions, else, hide it.
For that I wrote this event:
‘-------------------------------------------------------------------
Private Sub Form_Current()
Dim TempRcdst As Recordset
Forms![EmployeeRevision]![EmployeeRevisionDetail].SetFocus ‘This is Sub Form
#1
Set TempRcdst = CurrentDb.OpenRecordset("SELECT * FROM
EmployeesCompensationTemp WHERE EmployeesCompensationTemp.EmployeeID=" &
[Forms]![EmployeeRevision]![EmployeeRevisionDetail].[Form]![EmployeeID] & ";")
If TempRcdst.EOF = True Then
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Visible =
False
Else
Forms![EmployeeRevision]![EmployeeRevisionProposedDetail].Visible = True
End If
TempRcdst.Close
End Sub
‘-------------------------------------------------------------------------
The problem is, Access breaks in line Forms![EmployeeRevision]!
[EmployeeRevisionProposedDetail].Form.Requery and says:
“Record Has Been Deleted”
Any clue?