473,417 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

delete a record with required fields

i have a form that has required fields and i have a delete button, created by
the wizard, that has this code for onclick:

Private Sub cmddeleterecord_Click()
On Error GoTo Err_cmddeleterecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_cmddeleterecord_Click:
Exit Sub

Err_cmddeleterecord_Click:
MsgBox Err.Description
Resume Exit_cmddeleterecord_Click
End Sub

5 of the 9 fields on this form are required. if you try to delete the record
w/o filling in all of these fields, access won't let you. how can i bypass
this and allow a user to click the delete button and either delete the
incomplete record or clear the form? thanks.

--
Message posted via http://www.accessmonster.com
Nov 29 '05 #1
3 3009
Press the Esc key twice to undo the record.

You will then be able to move focus to the Delete button (which won't do
anything helpful if you are already at a new record.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"ka******@comcast.net via AccessMonster.com" <u15580@uwe> wrote in message
news:580f139eb3d96@uwe...
i have a form that has required fields and i have a delete button, created
by
the wizard, that has this code for onclick:

Private Sub cmddeleterecord_Click()
On Error GoTo Err_cmddeleterecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_cmddeleterecord_Click:
Exit Sub

Err_cmddeleterecord_Click:
MsgBox Err.Description
Resume Exit_cmddeleterecord_Click
End Sub

5 of the 9 fields on this form are required. if you try to delete the
record
w/o filling in all of these fields, access won't let you. how can i
bypass
this and allow a user to click the delete button and either delete the
incomplete record or clear the form? thanks.

Nov 29 '05 #2
Quick and dirty solution:

Private Sub cmddeleterecord_Click()
if isnull(me.requiredField1) or isnull(me.requiredField2) then
'this is an as yet unsaved record because
'record will not save if required field is missing.
'simply re-set (undo) to empty all fields.
me.undo
else
'delete the record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
end if
End Sub

Then add "is not null" to the validation property of the required
fields to make sure that users cant set them to null on an already
existing record - otherwise there could be a loop-hole in the above
code.

Nov 29 '05 #3
thank you. that is EXACTLY what i was looking for. perfect.

greg

BillCo wrote:
Quick and dirty solution:

Private Sub cmddeleterecord_Click()
if isnull(me.requiredField1) or isnull(me.requiredField2) then
'this is an as yet unsaved record because
'record will not save if required field is missing.
'simply re-set (undo) to empty all fields.
me.undo
else
'delete the record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
end if
End Sub

Then add "is not null" to the validation property of the required
fields to make sure that users cant set them to null on an already
existing record - otherwise there could be a loop-hole in the above
code.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200511/1
Nov 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
1
by: Per | last post by:
Hi, I have a problem that I can't figure out. I have a database application to keep track of boxes that contain files. For data entry, I have a form with a main form section for the box-specific...
1
by: Richard | last post by:
A shipment of material is received. The shipment contains several items. Each item is assigned an internal tracking number for auditing purposes and further processed. The tracking number is...
3
by: igendreau | last post by:
I'm trying to clean up a database of mine, and I need to convert some old DAO code over to ADO. When I was using DAO, I had no problem running this script and deleting the record using rs.Delete. ...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
10
beacon
by: beacon | last post by:
Hi everybody, This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure. Anyway, I have a form with a (continuous) subform, and on the subform I...
31
by: matthewslyman | last post by:
I have an unusual design and some very unusual issues with my code... I have forced Access to cooperate on everything except one issue - record deletion. My form design involves a recursively...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.