Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 5th, 2004, 09:56 AM
Registered User
 
Join Date: Sep 2004
Location: Highlands Ranch, CO, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error 3201: Cannot add record in child form/table

Assistance needed for Button Code on Parent Form:

Assistance needed for Button Code on Parent Form.
Syntax problem with the following line in adding record and/or updating value of CustomerID in child table:
     Me.CustomerID = Forms.Item(FrmCustomerDetail).Controls(ActionLog). Value

Background:
    FrmCustomer (parent) is based upon TblCustomers. The button on this form opens FrmActionLog (child), which is based upon TblActionLog. (FrmActionLog is a separate pop-up form and not an embedded sub-form)

    TblCustomers holds customer contact information. TblActionLog holds telephone call information/history. There is a one-to-many relationship between TblCustomers and TblActionLog and linked by CustomerID.

Problem Statement:
     After adding a new customer to TblCustomers (parent) there is not a matching record in TblActionLog (child) with the matching and new CustomerID.

     When a customer record is displayed in FrmCustomer and the user clicks on the button to open FrmActionLog the detail record displays CustomerID = 0. Then, when trying to input information into FrmActionLog (and into TblActionLog) and Error message 3201 is returned.

    [Note: The error message in this instance appears to be misleading. “You cannot add or change a record because a related record is required in table “TblCustomers”. Actually, the problem is that there is no matching record in TblActionLog !!

A little something is needed for the Button Code:

Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Me.CustomerID = 0 Or IsNull(Me.CustomerID) Then
    Me.CustomerID = Forms.Item(FrmCustomerDetail).Controls(ActionLog). Value
          'I do not understand the syntax for "Controls" part of the line above. I'm trying to obtain the CustomerID value from the FrmCustomerDetail and place it into Me.CustomerID (e.g. FrmActionLog). In this example "ActionLog" is the name of the button on the FrmCustomerDetail.

    End If
End Sub

Guidance and Suggestions will be very much appreciated !!
Thank you!
Jerry


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Record to table from form AlForum29 Access VBA 2 January 2nd, 2013 08:46 PM
Using DetailsView control to add record to Child megnin ASP.NET 1.x and 2.0 Application Design 0 September 5th, 2008 03:37 PM
Add record form bunkerbang Access VBA 5 September 12th, 2007 12:17 AM
Add record to another table with radiobutton Dejitan ASP.NET 1.0 and 1.1 Basics 8 January 11th, 2007 08:24 AM
ADO record copy and add to table Freddyfred Access 2 February 16th, 2005 09:36 PM



All times are GMT -4. The time now is 06:07 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.