Required Data and Deleting Question

  • Thread starter Thread starter Kerman
  • Start date Start date
K

Kerman

I have a form where I have 5 fields set to "Required" in tbl. I also have
20 other fields not set to "Required" I also have a "delete this record"
button. The problem is when I want to delete the current record. I cant do
it unless all the fields that are required are populated with data. I end
up putting in dummy data and then delete the record. Is there a way around
this? Thanks...Randy
 
That's NOT the normal behaviour. Access / Jet doesn't care whether the
Fields are filled in or not when you delete the Record.

Possibly some code in your Form is trying to save the Record or you have
some validation code in your Form being run when you click the Delete
button. In particular, do you have any Control_BeforeUpdate / AfterUpdate /
LostFocus / Exit Event Procedure in your code? Put a break at the start of
each one of them and see what happens when you click the button.
 
How and where do I put in a break..Randy I do have some code for saving the
record, here's an example:

Private Sub Preview_This_Field_Note_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Dim strDocName As String
Dim strWhere As String

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Preview"
Else
strDocName = "Inedible Notesheet"
strWhere = "[AnalysisID]=" & Me![AnalysisID]
DoCmd.OpenReport strDocName, acPreview, , strWhere
End If

End Sub
 
--
HTH
Van T. Dinh
MVP (Access)



Kerman said:
How and where do I put in a break..Randy I do have some code for saving the
record, here's an example:

Private Sub Preview_This_Field_Note_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Dim strDocName As String
Dim strWhere As String

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Preview"
Else
strDocName = "Inedible Notesheet"
strWhere = "[AnalysisID]=" & Me![AnalysisID]
DoCmd.OpenReport strDocName, acPreview, , strWhere
End If

End Sub

That's NOT the normal behaviour. Access / Jet doesn't care whether the
Fields are filled in or not when you delete the Record.

Possibly some code in your Form is trying to save the Record or you have
some validation code in your Form being run when you click the Delete
button. In particular, do you have any Control_BeforeUpdate /
AfterUpdate
/
LostFocus / Exit Event Procedure in your code? Put a break at the start of
each one of them and see what happens when you click the button.

--
HTH
Van T. Dinh
MVP (Access)



cant
 
This is the one. The If statement:

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If

tries to save the Record if the Form is dirtied and it is where JET Engine
check the "Required" values.

I can't remember all the arguments of the DoMenuItem (since it uses the Menu
Structure of Access 95 which I haven't used since 1998) but I got the
feeling that this also tries to save the Record and somehow you duplicated
the action with Me.Dirty = False.

To put a Breakpoint on a line of code, you simply click the vertical grey
bar just to the left of the line of code. Alternatively, put the cursor on
the line and use the Menu Debug / Toggle Breakpoint or simply hit F9.

I am not sure what you are trying to do but now that we identified the
problem, you need to re-write your code to bypass it.
 
The code I have is meant to Preview a record based only on the data of the
current form, or one specific record showing on the screen (Form). Without
saving or refreshing the data in this code, a report from a previous record
is previewed not the current record. The If statement is meant to inform
the user that the new record is emty and may need to select a populated
record...I hope I didnt confuse you..Thanks..Randy
Van T. Dinh said:
This is the one. The If statement:

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If

tries to save the Record if the Form is dirtied and it is where JET Engine
check the "Required" values.

I can't remember all the arguments of the DoMenuItem (since it uses the Menu
Structure of Access 95 which I haven't used since 1998) but I got the
feeling that this also tries to save the Record and somehow you duplicated
the action with Me.Dirty = False.

To put a Breakpoint on a line of code, you simply click the vertical grey
bar just to the left of the line of code. Alternatively, put the cursor on
the line and use the Menu Debug / Toggle Breakpoint or simply hit F9.

I am not sure what you are trying to do but now that we identified the
problem, you need to re-write your code to bypass it.

--
HTH
Van T. Dinh
MVP (Access)



Kerman said:
How and where do I put in a break..Randy I do have some code for saving the
record, here's an example:

Private Sub Preview_This_Field_Note_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Dim strDocName As String
Dim strWhere As String

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Preview"
Else
strDocName = "Inedible Notesheet"
strWhere = "[AnalysisID]=" & Me![AnalysisID]
DoCmd.OpenReport strDocName, acPreview, , strWhere
End If

End Sub
 
No problems with the If Me.NewRecord ...

However, my whole idea is that something else in your code is trying to save
the Record when you are actually trying to delete the Record.

Since I don't know your form's setup/functionalities or all the code you
have on your Form, you have to find out what's going on in your Form (using
the Breakpoints) when you try to delete the Record and fix it accordingly.
Certainly more things happen than simply deleting the Record as per my first
reply.

HTH
Van T. Dinh
MVP (Access)
 
Thanks for your ideas..I'll check it out
Van T. Dinh said:
No problems with the If Me.NewRecord ...

However, my whole idea is that something else in your code is trying to save
the Record when you are actually trying to delete the Record.

Since I don't know your form's setup/functionalities or all the code you
have on your Form, you have to find out what's going on in your Form (using
the Breakpoints) when you try to delete the Record and fix it accordingly.
Certainly more things happen than simply deleting the Record as per my first
reply.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top