Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 March 26th, 2009, 05:17 AM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA string bug?

I've got an Access application which is behaving rather strange. It has trouble handling strings correctly in VBA at random places.

For example:
Code:
strSQL = "SELECT " & strOmschrijving & " AS Omschrijving, CStr(V.Jaar) + ' ' + Format(V." & strPeriode
strSQL = strSQL & ",'00') AS Bereik1, " & CStr(intNiveau) & " AS Niveau, " & strID & " AS ID, "
strSQL = strSQL & CStr(GeefMaxSortering + 1) & " + (3000-V.Jaar)*10000 - V." & strPeriode & " AS Sortering, " & vbNewLine
When stepping through the code it leaves out the bold part " AS ID, ". But when I add an extra space somewhere in that line, than it behaves correctly.

Similar problems in other parts of the application too. I've already tried decompiling etc, to clean things up. I even made a new mdb and imported all objects and code, but no effect.

Has someone every seen anything like this too? I cannot imagine being the first to have this problem.

Another example would be:
Code:
strSQL = "SELECT B.SorteerCentrumID, B.PeriodeID, PER.Jaar, PER.Week, PER.Tijdvak, B.Datum, B.ProcesCode, "
strSQL = strSQL & "Sum(Nz(B.WaardeOchtend,0)) AS WaardeOchtend, Sum(Nz(B.WaardeMiddag,0)) AS WaardeMiddag, " & vbNewLine
strSQL = strSQL & "Sum(Nz(B.WaardeAvond,0)) AS WaardeAvond, Sum(Nz(B.WaardeNacht,0)) AS WaardeNacht, "
strSQL = strSQL & IIf(blnIsSorteerdag, "Sum(Nz(B.WaardeNachtVolgend,0)) AS WaardeNachtVolgend ", "NULL AS WaardeNachtVolgend ")
Here it leaved out the entire first line. When stepping through the code the string would still be empty after executing only the first line. But again, by adding a space somewhere inside the string, it would work again.

This is Access 2003 SP3, VBA6.3.
 
Old March 26th, 2009, 07:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello.. IF your string is defined like strSQL as string, then this is a first time. Are you sure that in no other place you are touching this strings?
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 26th, 2009, 08:19 AM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Pls look at example 2. When I step through code and execute the first line, strSQL stays empty. Im developing in VB(A) (MCSD VB6) for more than 10 yrs now and havent seen anything like this before.
 
Old March 26th, 2009, 08:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Me neither, that why I asked you... Just a stupid question, what if you change the lines, I mean put the first line into the second position and try that (I know It will make the SQL useless, I want you to try if maybe there is a problem with the compiler...)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 26th, 2009, 08:29 AM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've added a empty line before the line and then it works. But this will not be a lasting solution, changes are that now some code in some other module wille have similar problem.
 
Old March 26th, 2009, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Did you find anything on google?? I really never saw a problem like that...
What if you try that in a new database?? do it work fine?? Maybe the database is corrupt and that why is working bad...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 26th, 2009, 08:46 AM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ive tried a complete new database as well. No help. Have searched Google extensively, no help. Although i did find one topic somewhere where someone had similar problem, but no real solution was given other than rewriting query.

http://techreport.com/forums/viewtopic.php?f=20&t=62576

Believe me, Ive tried anything now.
 
Old March 26th, 2009, 09:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Ok, Another weird Idea.. what if you change the type of strSql to variant?? do it change anything???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 26th, 2009, 09:43 AM
Authorized User
 
Join Date: Mar 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does not help.
 
Old March 26th, 2009, 09:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

And in another PC?
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
Trim a string in VBA lryckman Access VBA 2 January 19th, 2007 08:39 AM
Span Bug? interrupt HTML Code Clinic 4 June 20th, 2006 09:40 AM
Bug happens guoqi BOOK: ASP.NET Website Programming Problem-Design-Solution 0 October 13th, 2003 01:35 PM
String access by character bug in multi-dimensiona richard.york Pro PHP 1 September 6th, 2003 05:57 PM





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