Solved

append not working in linked table

Posted on 2013-01-29
7
233 Views
Last Modified: 2013-01-30
After testing with a local mdb table I imported this table to sql server 2005 and linked it in access.

Now it doesn't seem to want to do the insert. What is wrong with the code below?

  Dim db As DAO.Database
    Dim RcdSet As DAO.Recordset
    
    Dim sqlErrors As String
    Set db = CurrentDb()
    sqlErrors = "Select * From tblErrorLog"
    Set RcdSet = db.OpenRecordset(sqlErrors, dbOpenDynaset)

    With RcdSet
    
        .AddNew
            !ErrorNumber = ErrEx.Number
            !ErrorDescription = ErrEx.Description
            !HostUserID = gintHostUserID
            
            ErrEx.Callstack.FirstLevel
            
            Do
                !CallStackInfo = !CallStackInfo & _
                                    ErrEx.Callstack.ProjectName & "." & _
                                    ErrEx.Callstack.ModuleName & "." & _
                                    ErrEx.Callstack.ProcedureName & ", " & _
                                    "#" & ErrEx.Callstack.LineNumber & ", " & _
                                    ErrEx.Callstack.LineCode & vbCrLf & _
                                    ErrEx.Callstack.VariablesInspector.DumpAll & vbCrLf
            Loop While ErrEx.Callstack.NextLevel
            
        .Update
        
        .Close
        
    End With
    
    Set RcdSet = Nothing

Open in new window

0
Comment
Question by:Shawn
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38833441
What is going wrong ?
Do you get an error message or what?


And what does this mean?
 ErrEx.Callstack.FirstLevel

it's not any vba I've ever seen.
0
 
LVL 1

Author Comment

by:Shawn
ID: 38833451
>> Do you get an error message or what?

no message at all. just no insert

>>ErrEx.Callstack.FirstLevel

it's from a product called vbWatchDog. amazing
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38833485
Does tblErrorLog have a Primary Key?  It might also need a timestamp field.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:Shawn
ID: 38833491
yes, it has a primary key.

I'm thinking there is a typo somewhere in the code but have been staring at it too long.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 38834363
You may need this:

Set RcdSet = db.OpenRecordset(sqlErrors, dbOpenDynaset, dbSeeChanges)

and, as noted, a Timestamp field.

Also, do open the linked table manually and try to add a record with data as the code would do.

/gustav
0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 38837249
thanks Gustav. Was missing the dbSeeChanges.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 38838496
You are welcome!

/gustav
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now