Create a module and use arrays so that you can pass any data entry form
to the module. The following code simplifies what you have, and I can
pass any form for any recordset to this module.
I use an array to store all data entered on the form, and bring that
into the module. The recordset is also decided at the form level, and
passed to the module.
Sub InsertRecords(vData As Variant, rsRecord As Recordset)
On Error GoTo InsertRecords_Err:
Dim i As Integer
'Insert data into recordset, we handle temp information differently.
rsRecord.AddNew
For i = 0 To UBound(vData)
rsRecord.Fields(i + 1) = vData(i)
Next
End If
rsRecord.Update
As for your code, did you start with rsRecord.AddNew? This is necessary
before updating any recordset.
Craig Gross
Sr. Pub Reporting and Profitability Analyst
Baker & Taylor
1120 U.S. Highway 22 East
PO Box 6885
Bridgewater NJ 08807
[EMAIL PROTECTED]
Tel: 908-541-7197
Fax: 908-541-7862
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Friday, April 14, 2006 8:17 AM
To: [email protected]
Subject: Re: [Access VBA Central] Bound Forms vs Unbound Forms in Access
Thanks for the response. I do currently have an unbound form set up but
I am
having several errors. After I add 5-6 records to the form I "Save All
Changes
to the Database" I receive this error: Multiple-step operation
generated
errors. Check each status value. It bombs on the third line. I have
it set-
up as an interger because it contains a value. Can you give me any
ideas.
Another question is when I add several records to the form where is this
stored
until I add it to the database?
Sub SaveCurrentRecord()
'save the values in the controls on the form to the current record
'in the local disconnected recordset
'1 If Not rsCustomer.BOF And Not rsCustomer.EOF Then
'2 rsCustomer!txtCustomer = Me.txtCustomer
'3 rsCustomer!intDCnt = Me.intDCnt
rsCustomer!intDRfds = Me.intDRfds
rsCustomer!intDRfdSales = Me.intDRfdSales
rsCustomer!intDNetSales = Me.intDNetSales
rsCustomer!intDAirComm = Me.intDAirComm
rsCustomer!intICnt = Me.intICnt
rsCustomer!intIRfds = Me.intIRfds
rsCustomer!intIRfdSales = Me.intIRfdSales
rsCustomer!intINetSales = Me.intINetSales
rsCustomer!intIAirComm = Me.intIAirComm
rsCustomer!intTNetSales = Me.intTNetSales
rsCustomer!intTourComm = Me.intTourComm
rsCustomer!intSNetSales = Me.intSNetSales
rsCustomer!intShipComm = Me.intShipComm
rsCustomer!intRNetSales = Me.intRNetSales
rsCustomer!intRailComm = Me.intRailComm
rsCustomer!intCNetSales = Me.intCNetSales
rsCustomer!intCarComm = Me.intCarComm
rsCustomer!intHNetSales = Me.intHNetSales
rsCustomer!intHtlComm = Me.intHtlComm
rsCustomer!intSFCnt = Me.intSFCnt
rsCustomer!intSFNetSales = Me.intSFNetSales
rsCustomer!intSFComm = Me.intSFComm
rsCustomer!intMiscNetSales = Me.intMiscNetSales
rsCustomer!intMiscComm = Me.intMiscComm
rsCustomer!txtPeriod = Me.txtPeriod
rsCustomer.Update
End If
End Sub
[Non-text portions of this message have been removed]
Yahoo! Groups Links
This email and any attachments contain information from Baker & Taylor which
may
be confidential, privileged and/or protected by other legal rules. If you are
not the
intended recipient, you are hereby advised that any disclosure, copying,
distribution or
use of the contents of this email is prohibited. If you have received the email
in error,
please notify us by reply email immediately and then delete the email and your
reply
from your email system. NOTE: Baker & Taylor accepts no liability for the
contents of
this email. This email shall not operate to bind Baker & Taylor to any
contract, order
or other obligation.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AccessVBACentral/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/