Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate sub-form contents against main-form field

Status
Not open for further replies.

crystalreporting

Instructor
Feb 13, 2003
649
NZ
I have created a simple application to receive inventory items from a previously entered purchase order. The main-form captures the PO information i.e. PO Number, PO Line and Qty. Recieved.

I have a sub-form that is active if the item number on the PO is a serialized item i.e. the item number requires a serial number for each item that is received. The sub-form is only active if the item on the PO is flagged as being serialized. The sub-form writes serial numbers to a temporary table that is cleared each time the main-form is refreshed.

Once all of the information is captured on the main-form and (optionally) the sub-form I have a button to process the receipt. Currently this simply runs a macro that contains all of the queries that update the database to record the receipt.

My forms have a 'hole' that I need to plug - it's currently possible (for example) to enter a receipt for 2 serialized items on the main-form, but enter a different number of serial numbers on the sub-form. I need some way (maybe as part of the 'Process Receipt' button) to compare the number of serial numbers entered with the qty. to receive on the main-form and present a warining if they don't match. I need the macro/queries to process normally if the two values do match OK.

Peter Shirley
 
At the point you click the command button to process the receipt, what is the maximum number of serial numbers you would have
1. on the main form
2. on the sub form
I thought I had a solution for you until I realized I wasn't clear on the above.


"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Thanks for the response. I got it to work by using:

Private Sub Process_Receipt_Click()
Dim num_serial_count
num_serial_count = [Serial_Information_subform].Form.Recordset.RecordCount
If Me.qty_received <> num_serial_count Then
MsgBox "Receipt qty. does not match serial numbers", vbInformation, "IM Enter Receipts"
Cancel = True
Me.qty_received.SetFocus
Else
DoCmd.RunMacro "Process_Receipts"
End If
End Sub

Peter Shirley
 
Cool!

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top