Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows update causes access trouble?

Status
Not open for further replies.

AlexCuse

Programmer
Apr 13, 2006
5,416
US
I am just wondering if anyone else has experienced this.

I have a function called 'MkAccessDatabase(NewDatabaseName As String)' that does just what the name implies. This has been running smoothly for over a year. This morning, I got a compile error (ByRef Argument mismatch). This is only happening on a sub I have that calls the function twice. I had allowed windows to update itself on Friday.

My problem ended up being in my declaration of variables. It had been :
Code:
Dim dbName, db2Name As String

I had to give each it's own separate declaration line, and then it ran smoothly. Was there something flawed in how I was declaring the strings before? And if so, shouldn't it have crashed on me long before now?

Any idea why this is? I'm not sure what was updated, but I don't think any Access service pack was downloaded.

The problem is solved, I just would like to know if anyone has any insight into why it happened.

Thanks a lot,

Alex

Professor: But what about your superintelligence?
Gunther: When I had that there was too much pressure to use it. All I want out of life is to be a monkey of moderate intelligence who wears a suit. That's why I've decided to transfer to Business School.
Professor: NOOOOOOOOOOOO.
 
I don't know why you expereinced this problem, but I have an idea/comment that may help shed some light.

It was my understanding - and correct me if I am wrong here folks - that defining more than one variable in the same dim statement requires each variable be defined or it is defined as Variant by default.

So:
Dim dbName, db2Name As String
results in dbName being Variant and db2Name being string.

To properly define these two on the same Dim line, it should be:
Dim dbName As String, db2Name As String

Now, whether this caused your error - I can't say. But this is just something to know for good practice...Hope it helps.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Dim dbName, db2Name As String

means

Dim dbName as variant, db2Name As String

which is not what you intended. You were NOT creating dbName as a string.

What you should have:

Dim dbName as String, db2Name As String
 
This morning, I got a compile error (ByRef Argument mismatch).
As to why it happens all-of-a-sudden, I know that in previous versions--and so far it seems Access 2003--have an issue where not all modules are compiled all the time (ie, if you only click 'compile loaded modules' and not 'compile and save all modules').

Code--including functions with compile errors--runs fine as long the offending line is not stepped through.

I have had cases where I have documented evidence that I've called and ran a function with a compile error, but the function ran fine and never errored out. Then a day later (and there was indeed no changes whatsoever to the function) the compile error comes up.

I'm talking about big errors--missing End If's--things like that. Again, the code did not actually meet the area of the missing End If for example--but that very funcion ran fine with the missing End If harmlessly sitting in a block that never was hit. Only later did a compile error show itself--seemingly at random.

I know it sounds strange--and many are probably thinking I had to have mistakenly or unknowingly changed something. But this has happened on more than one occasion and there is no question that in some cases this code was old code, and one day Access decides to throw a compile error and expose an error that had been in a dusty unused block of code for months.
--Jim
 
Thanks for the feedback guys. I am certainly going to change my declarations going forward. I would think that because I was passing a variant to a function expecting a string it would have errored long ago, but perhaps the variant was being forced into a string data type in the past?

This function had been stable and running fine for months of daily use. Strange...

Thanks again,

Alex


Professor: But what about your superintelligence?
Gunther: When I had that there was too much pressure to use it. All I want out of life is to be a monkey of moderate intelligence who wears a suit. That's why I've decided to transfer to Business School.
Professor: NOOOOOOOOOOOO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top