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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error '49'. Bad DLL calling convention

Status
Not open for further replies.

snerting

Programmer
Oct 20, 2005
52
I have a wierd case going on right now. I'm sorting it under X-files..

I have a form which references several modules in a MDA. Now, at one of the functions in this MDA, the code breaks when trying to exit from that function ("Form Exit"), stating "Runtime error '49'. Bad DLL calling convention". Thing is, neither that function, nor the code calling it ever calls DLL's (other than those access might be calling by itself). I successfully step through the entire function without problems, but as I said, when I step out of the function it borks. The line calling it doesn't even apply the return value to anything, and the function is called properly.

Now, I have tried several things. I tried compact and repairing the .mda but that didn't work. The strangest thing is that when the form is loaded, and the functionality causing this is used, it borks. If I create a new record and hit the button, it still works. However, if I go into code-view and comment out the contents of the function, save, compile, comment it back in, save, compile... IT WORKS!! When I restart the form, it goes back to the same error.

Anyone?
 
A little mistake in the post there:
"If I create a new record and hit the button, it still works."
Should of course read:
"If I create a new record and hit the button, it still BORKS.
 
Ok, so I found a couple of lines of code that looked redundant of earlier functionality in the function, and just commented them out. So now it stopped raising the 49 error, but I'm not really at ease with this as the error sounds nasty and the "fix" shouldn't be related. So if anyone has heard of anything like it, I'd still like to hear about it.
 
Watch how you call a Sub as opposed to a Function.

Even though access will allow a call for Function Foo() like:
Foo

you should instead do:
x = foo()
--Jim
 
Uhrm, yes, sure, but such an error in calling functions wrongly should pop a byval error, not a bad dll calling convention. Anyway, I did try calling the function in various ways, like:

Foo
Call Foo
x = foo()

Didn't solve my problem.. Removing some, to my knowledge, random lines of code did solve it.
 
Just went through the same problem. In my case, the function accepted a string argument. I made it byval and it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top