Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

AddNew method question

Posted on 1999-07-19
4
Medium Priority
?
152 Views
Last Modified: 2010-04-30
Can anyone tell me what is wrong with this code?

I am trying to fill a table called CashBilling with some arrays.
But when I do a .AddNew method it's not taking it




Set mydatabaseCB = DBEngine(0).OpenDatabase(glocationofdb)
Set myTableCB = mydatabaseCB.OpenRecordset("CashBilling", dbOpenTable)

For s = 0 To 11
      myTableCB.AddNew
      myTableCB.Edit
      myTableCB("ProjectionID") = lngNewProjectID
      myTableCB("Month") = arMonthLables(s)
          myTableCB("CashPrevious") = arPrevCash(s) 'arrays...
          myTableCB("CashCurrent") = arCurCash(s) 'arrays...
         myTableCB("BillPrevious") = arPrevBill(s) 'arrays...
         myTableCB("BillCurrent") = arCurBill(s) 'arrays...
      myTableCB.Update
Next
0
Comment
Question by:eeevbeee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:kamall
ID: 1526000
use
    myTableCB("ProjectionID").Value = 'your value here'

instead of

    myTableCB("ProjectionID") = xxxx

Apply the same for all fields.
Also put a DoEvents before the Next statement.

Regards.
0
 
LVL 7

Expert Comment

by:kamall
ID: 1526001
Also don't forget to use the appropriate data types for the fields (string for string type, integer for integer, etc.).
0
 
LVL 2

Accepted Solution

by:
sun365 earned 200 total points
ID: 1526002
simple,
get rid of the object.edit

it will then work

0
 

Author Comment

by:eeevbeee
ID: 1526003
i guess this is what i was looking for as it now works. thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question