472,811 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Cancel/delete constrained new row created in continuous subform?

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 mandatory, unique and non-zero, but _cannot_ be
obtained or assigned automatically by Access (due to business rules
[perhaps part of the anti-productivity initiative ;) ]).

Table A is the receive table
Columns: AID, ReceiveDate, CompanyID

Table B is a item tracking number table
Columns: BID, AID, TrackingNumber, ItemTypeID, ItemCount

A frmReceiving shows the fields Date and Company, and has a continuous
subform (linked by AID) for showing/entering the tracking number of
each item of the shipment received.

Suppose the tracking number is _not_ available, but something was
entered for ItemTypeId or Count. At this point the record is
incomplete.
The data entrist has to cancel or delete the 'new item row having a
blank tracking number' and go ferret out the tracking number from the
control department before entering the type and count.

When the records edit pencil icon is right clicked, so as to be "Cut"
from the context menu, this dialog appears:
"The field 'frmReceiving.TrackingNumber' can't contain a null value
because the required property for this field is set to true. Enter a
value in this field."

To prevent spurious data, I don't want a dummy number entered, just so
the record can be deleted!

Q: What would be a good strategy for canceling the 'incomplete' new
item row ?

I would like to have a 'cancel' or 'delete' command icon in the
continuous subform, but only show it if the tracking number is
missing, or if the tracking number entered would fail the unique
constraint.

TIA,
Richard

Feb 1 '07 #1
1 2752
On Feb 1, 11:31 am, "Richard" <richard.goo...@devenezia.comwrote:
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 mandatory, unique and non-zero, but _cannot_ be
obtained or assigned automatically by Access (due to business rules
[perhaps part of the anti-productivity initiative ;) ]).

Table A is the receive table
Columns: AID, ReceiveDate, CompanyID

Table B is a item tracking number table
Columns: BID, AID, TrackingNumber, ItemTypeID, ItemCount

A frmReceiving shows the fields Date and Company, and has a continuous
subform (linked by AID) for showing/entering the tracking number of
each item of the shipment received.

Suppose the tracking number is _not_ available, but something was
entered for ItemTypeId or Count. At this point the record is
incomplete.
The data entrist has to cancel or delete the 'new item row having a
blank tracking number' and go ferret out the tracking number from the
control department before entering the type and count.

When the records edit pencil icon is right clicked, so as to be "Cut"
from the context menu, this dialog appears:
"The field 'frmReceiving.TrackingNumber' can't contain a null value
because the required property for this field is set to true. Enter a
value in this field."

To prevent spurious data, I don't want a dummy number entered, just so
the record can be deleted!

Q: What would be a good strategy for canceling the 'incomplete' new
item row ?

I would like to have a 'cancel' or 'delete' command icon in the
continuous subform, but only show it if the tracking number is
missing, or if the tracking number entered would fail the unique
constraint.
To force users to enter a tracking number you can check the tracking
number field in the beforeupdate event of your form. If there isn't
one you can cancel (Cancel = True) and give user the option (using a
message box perhaps) of entering something by setting focus back to
the tracking number field or to discard the partial record by using
the Undo method of the form. Alternately you could use the error
event of the form itself to trap for both missing and invalid tracking
number:

Private Sub Form_Error(DataErr As Integer, Response As Integer)

Select Case DataErr
Case 3058
MsgBox "Missing tracking number"
txtProductID.SetFocus
Case 3022
MsgBox "Invalid tracking number"
txtProductID.SetFocus
Case Else
MsgBox "Some other error"
txtProductID.SetFocus
End Select

Response = acDataErrContinue

End Sub

Hope this helps,
Bruce

Feb 1 '07 #2

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

Similar topics

4
by: Deano | last post by:
If I create 2 or more records in my subform and I then delete the main record, then all the controls on my subform disappear. Yet if there is only one record in the subform then it gets deleted...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
1
by: gavo | last post by:
Hello everyone! Using A2K i have a form(a) with a subform(b) and within the subform there is a continuous subform(c). in the subform (b) there is a command button used to call a public...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
0
by: ApexData | last post by:
I have a subForm sitting on my MainForm. The subForm is a continuous form and Does Not have its RowSource tied to the main Form. If the subform is tested in isolation, outside the MainForm and I...
2
by: Paul | last post by:
How can you cancel a row insert programmatically? I'm not talking about the Form_BeforeInsert(Cancel As Integer). I have a continuous form. A new row is started. Code for the continuous form...
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.