Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3
This is the forum to discuss the Wrox book Access 2007 VBA Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Armen Stein; ISBN: 9780470047033
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 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 November 2nd, 2009, 02:57 PM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default "Out of Memory" When I'm clearly not

Hello,

I'm an experience Excel VBA coder venturing into the Access unknown. For anyone familar with the Bloomberg COM V3 API, I'm attempting to marry that to our Portfolio Management Access Database. Here's my problem:

As I'm stepping through the return data from Bloomberg and inserting it into my table, after 5 fields it gives me an "Run-time error '7': Out of memory". MSACCESS is not using any additional memory, and the task manager performance windows don't show any spike in activity. This same code works just fine inserting the same data into an excel worksheet.

Anyone have any ideas? I am the only user of this data. Thanks.

Code:
 
Private Sub session_ProcessEvent(ByVal obj As Object)
    On Error GoTo errHandler
 
    Dim eventObj As blpapicomLib.Event
    Dim dbs As DAO.Database
    Dim rstbl1 As DAO.Recordset
    Dim rstbl2 As DAO.Recordset
 
    Set eventObj = obj
    Set dbs = CurrentDb
    Set rstbl1 = dbs.OpenRecordset(wrktbl1, dbOpenTable)
    Set rstbl2 = dbs.OpenRecordset(wrktbl1 & " BH", dbOpenTable)
    rstbl2.MoveFirst
 
    'If  Then
        If eventObj.EventType = PARTIAL_RESPONSE Or eventObj.EventType = RESPONSE Then
            Dim it As blpapicomLib.MessageIterator
            Set it = eventObj.CreateMessageIterator()
 
            Do While it.Next()
                Dim msg As Message
                Set msg = it.Message
 
                Dim numSecurities As Integer
                numSecurities = msg.GetElement("securityData").NumValues
                Dim i As Integer
                rstbl1.Index = "PrimaryKey"
 
                For i = 0 To numSecurities - 1
                    Dim Security As Element
                    Set Security = msg.GetElement("securityData").GetValue(i)
                    rstbl1.Seek "=", Left(Security.GetElement("security").Value, 9)
                    Dim fields As Element
                    Set fields = Security.GetElement("fieldData")
                    Dim a As Integer
                    Dim numFields As Integer
                    numFields = fields.NumElements
                    If Not rstbl1.NoMatch Then
                      For a = 0 To numFields - 1
                        'If IsNull(rstbl1) Then
                          Set rstbl1 = dbs.OpenRecordset(wrktbl1, dbOpenTable)
                          rstbl1.Index = "PrimaryKey"
                          rstbl1.Seek "=", Left(Security.GetElement("security").Value, 9)
                        'End If
                        Dim field As Element
                        Set field = fields.GetElement(a)
                        X = 1
                        found = False
                        Do Until found
                          If StrComp(field.Name, rstbl2.fields(X).Value, vbTextCompare) = 0 Then
                            found = True
                          Else
                            X = X + 1
                          End If
                        Loop
                        rstbl1.Edit
                        rstbl1.fields(X).Value = field.Value  <-- Error occurs here.
                        rstbl1.Update
                        rstbl1.Close
                        Set rstbl1 = Nothing
                      Next
 
                    End If
                Next
            Loop
        End If
    'End If
 
    Exit Sub
 
errHandler:
    Dim errmsg As Variant
    errmsg = Err.Description
    MsgBox errmsg
 
    rstbl2.Close
    Set eventObj = Nothing
    Set dbs = Nothing
    Set rstbl1 = Nothing
    Set rstbl2 = Nothing
 
End Sub
I should mention that I tried to minimze the un-updated data by clearing out the object after each field update. Trying to do it all at once (updating each field before running the .update) ends with the same error after 5 field updates.
The Following User Says Thank You to Ahrenl For This Useful Post:
j0el (April 14th, 2010)
 
Old April 14th, 2010, 03:04 AM
Registered User
 
Join Date: Apr 2010
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default Database validation

Hello Ahrenl,

Just let you know I am Joel. is that the codes for DH database validation?!


Rgrds,
Zx




Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 10:19 AM
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM





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