Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2005, 06:35 AM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ids problem on subform

I have a for for making orders called NordersMaken with a subform NordersDetails. Here is some info on my tables:

tblOrders (=form NordersMaken)
OrderId
OrderDate
Seller
Customer
...

tblOrderDetails (= Form NordersDetails)
OrderDetailId
OrderId
ProductId (from tblProducts)
BlowerId (from tblBlowers)
Price
...

tblProducts
ProductId
Ref
Serial
Avail (yes/no) /for item ordered = not available (value yes/true)
uit (yes/no) / for item invoiced = out of wharehouse (value yes/true)

tblBlowers
BlowerId
Type
Serial
Available (yes/no) /for item ordered = not available (value yes/true)
out (yes/no) / for item invoiced = out of wharehouse (value yes/true)

From the form Products(tblProducts) I send the ProductId intot he subform, NordersDetails and set the focus on the main form (NordersMaken) with this:
Code:

DoCmd.OpenForm stDocName, , , , acFormAdd Forms!NordersMaken.Form!OrderDatectrl = Date Forms!NordersMaken.NordersDetails.Form!Serial = Me.ProductId

The problem: when I try to change details in the subform (NordersMaken) like Price I get an error message saying that the JETDB couldn't find the record OrderDetails.BlowerId. Just because I didn't select it. what if I don't need/want to? How could I leave it blank and/or avoid those errors?
I tried catching the error on the subform on GotFocus and on LostFocus I added this:

If Err = 3101 Then Err.Clear

I already changed the relationships from one-to-many to normal for 'tblProducts' and 'tblBlowers' with 'tblOrderDetails'. But the error keeps appearing and doesn't let me do anything else if I don't select them both. Any suggestions?
Edit/Delete Message

 
Old December 9th, 2005, 05:30 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Have you made them required fields in your table design? And/or have you enforced referential integrity in the relationships? Either one of these may cause it to become a requirement for inserting the record.

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Subform problem fatrich Access VBA 6 October 4th, 2007 08:02 PM
Print subform problem J.K.W.Y. Access 4 April 25th, 2006 06:21 AM
subform update problem Derek_05 Access 8 February 3rd, 2006 01:22 AM
Access SubForm Problem jscully Access 9 August 29th, 2005 03:03 PM
Filtering Subform Problem sherr8 Access 4 May 19th, 2004 10:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.