Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 January 17th, 2012, 01:19 PM
Authorized User
 
Join Date: Nov 2011
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default Could someone help with a RunTime Error

I'm trying to write new code. I have to admit I've never been in traditional training...can you tell me what I'm doing wrong?

thanks!

Code:
Function AppendCBNR()
On Error GoTo m_Err
Dim mySQL As String


    DoCmd.SetWarnings False
    mySQL = "INSERT INTO Chrgback_NonReversal ( [CBVND#], CBTHED, CBTHAM, CBNSRF, CBTHAF, CBNRDT, CBRAMT, CBNRAM, CBCRNO, CBCRSQ, CBCUST, [CBORD#], CBORLN )"
    mySQL = mySQL & "SELECT AUBLIB_FPCBNRDT.[CBVND#], AUBLIB_FPCBNRDT.CBTHED, AUBLIB_FPCBNRDT.CBTHAM, AUBLIB_FPCBNRDT.CBNSRF, AUBLIB_FPCBNRDT.CBTHAF, AUBLIB_FPCBNRDT.CBNRDT, AUBLIB_FPCBNRDT.CBRAMT, AUBLIB_FPCBNRDT.CBNRAM, AUBLIB_FPCBNRDT.CBCRNO, AUBLIB_FPCBNRDT.CBCRSQ, AUBLIB_FPCBNRDT.CBCUST, AUBLIB_FPCBNRDT.[CBORD#], AUBLIB_FPCBNRDT.CBORLN"
    mySQL = mySQL & "FROM AUBLIB_FPCBNRDT;"
    
  On Error GoTo 0

       db.Execute mySQL, dbFailOnError


    DoCmd.SetWarnings True
    Beep
    MsgBox "CBNR Table Complete!", vbOKOnly, ""


m_Exit:
    Exit Function

m_Err:
    MsgBox Error$
    Resume m_Exit

End Function
 
Old January 18th, 2012, 02:27 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

You need to add a space in some places


for example:
mySQL = mySQL & "SELECT ...
and
mySQL = mySQL & "FROM AUBLIB_FPCBNRDT;
needs to be

mySQL = mySQL & " SELECT ...

and

mySQL = mySQL & " FROM AUBLIB_FPCBNRDT;


Try:

Code:
Function AppendCBNR()
On Error GoTo m_Err
Dim mySQL As String


    DoCmd.SetWarnings False
    mySQL = "INSERT INTO Chrgback_NonReversal ( [CBVND#], CBTHED, CBTHAM, CBNSRF, CBTHAF, CBNRDT, CBRAMT, CBNRAM, CBCRNO, CBCRSQ, CBCUST, [CBORD#], CBORLN )"
    mySQL = mySQL & " SELECT AUBLIB_FPCBNRDT.[CBVND#], AUBLIB_FPCBNRDT.CBTHED, AUBLIB_FPCBNRDT.CBTHAM, AUBLIB_FPCBNRDT.CBNSRF, AUBLIB_FPCBNRDT.CBTHAF, AUBLIB_FPCBNRDT.CBNRDT, AUBLIB_FPCBNRDT.CBRAMT, AUBLIB_FPCBNRDT.CBNRAM, AUBLIB_FPCBNRDT.CBCRNO, AUBLIB_FPCBNRDT.CBCRSQ, AUBLIB_FPCBNRDT.CBCUST, AUBLIB_FPCBNRDT.[CBORD#], AUBLIB_FPCBNRDT.CBORLN"
    mySQL = mySQL & " FROM AUBLIB_FPCBNRDT;"
    

' send the SQL to the immediate window ( ctrl-g) 

Debug.Print  mySQL



  On Error GoTo 0

       db.Execute mySQL, dbFailOnError


    DoCmd.SetWarnings True
    Beep
    MsgBox "CBNR Table Complete!", vbOKOnly, ""


m_Exit:
    Exit Function

m_Err:
    MsgBox Error$
    Resume m_Exit

End Function

To help debug this SQL you can go to the immediate windows and copy and paste the SQL to the Query Designer in SQL view. Switch back to Design view to see if there are any errors.
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old January 18th, 2012, 10:42 AM
Authorized User
 
Join Date: Nov 2011
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Okay I see where you added spaces.....I've added your code to the VBA Module (I know it says SQL, but it's VBA in Access) and it errors on
Code:
db.Execute mySQL, dbFailonError
And when I look at the "Immediate" Window it provides the insert code...
Code:
 INSERT INTO Chrgback_NonReversal ( [CBVND#], CBTHED, CBTHAM, CBNSRF, CBTHAF, CBNRDT, CBRAMT, CBNRAM, CBCRNO, CBCRSQ, CBCUST, [CBORD#], CBORLN )  SELECT AUBLIB_FPCBNRDT.[CBVND#], AUBLIB_FPCBNRDT.CBTHED, AUBLIB_FPCBNRDT.CBTHAM, AUBLIB_FPCBNRDT.CBNSRF, AUBLIB_FPCBNRDT.CBTHAF, AUBLIB_FPCBNRDT.CBNRDT, AUBLIB_FPCBNRDT.CBRAMT, AUBLIB_FPCBNRDT.CBNRAM, AUBLIB_FPCBNRDT.CBCRNO, AUBLIB_FPCBNRDT.CBCRSQ, AUBLIB_FPCBNRDT.CBCUST, AUBLIB_FPCBNRDT.[CBORD#], AUBLIB_FPCBNRDT.CBORLN  FROM AUBLIB_FPCBNRDT;
Any more suggestions?
 
Old January 19th, 2012, 01:14 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Quote:
To help debug this SQL you can go to the immediate windows and copy and paste the SQL to the Query Designer in SQL view. Switch back to Design view to see if there are any errors
Did you try this?
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old January 19th, 2012, 01:51 PM
Authorized User
 
Join Date: Nov 2011
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I did and everything is still the same. No difference.
 
Old January 20th, 2012, 06:46 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Quote:
Originally Posted by SunnySide View Post
I did and everything is still the same. No difference.
Did the SQL generate any errors in the query design?

Was there an error when you ran the SQL in the query designer?
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old January 23rd, 2012, 02:51 PM
Authorized User
 
Join Date: Nov 2011
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

When it errors it highlights the "db.Execute mySQL, dbFailonError"


My understanding is the immediate window provides the code it's questioning and places a correct version. I copy pasted the code in SQL and it continued to give me the same error and provides the same code, and I checked there wasn't anything that I saw that was different about it. I would like for this to work, but I'm looking at another option to get by. If this works it would be a simpliar process. These tables are really large and hard to work with...so if I can reduce the amount of information it would help.
 
Old January 24th, 2012, 01:50 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Quote:
My understanding is the immediate window provides the code it's questioning and places a correct version
Correct version of what? All the Debug.Print does is place the SQL in the immediate windows so that you ca look at it to find the syntax error.


It would really help to know the error message. What is the exact error message?
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old January 27th, 2012, 02:03 PM
Authorized User
 
Join Date: Nov 2011
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I just wanted to let you know I was pulled off of this for now. I'll come back to it as soon as I can.
 
Old January 28th, 2012, 12:36 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Thanks for the update.

We will be here when you get back to this project.
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015





Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Error in '/' Application - Runtime Error leeWozyWarren BOOK: Beginning ASP.NET 4 : in C# and VB 10 November 22nd, 2011 06:51 PM
Microsoft VBScript runtime error '800a000d' error futurehype Classic ASP Professional 20 May 23rd, 2011 10:47 PM
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
Runtime Error whiterainbow ASP.NET 2.0 Professional 2 September 12th, 2006 01:20 AM
mysterious error runtime error '451' coyotworks Excel VBA 1 May 12th, 2006 03:57 PM





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