Using public function from private sub?

Yes, you don't need to declare statuscode as an integer in your form code!
 
AncientOne said:
Yes, you don't need to declare statuscode as an integer in your form code!

Why don't I need to declare it, can you explain?

I also tried:


statusCode = cbStatus(CInt(Me!chargebackId))


With the same results ....
 
AncientOne said:
Yes, you don't need to declare statuscode as an integer in your form code!

?
 
No, that was a stupid error on my part, confusing the variable with the field name. Put it down to age...
 
Ahh, it's okay, I figured. Considering I'm using Option explicit it wouldn't be possible to avoid that declaration anyway :)

Okay, this is driving me nuts! I'm looking at the the evaluation VBA editor shows in the 'tooltip' box that pops up when you hover over a chunk of code. I'll show you what it shows for each:



Code:

statusCode = cbStatus(Me!chargebackId)


Tooltip contents:

statusCode = 0
cbStatus(Me!chargebackId) = <Type mismatch>
Me!chargebackId = 43
 
Clutching at straws now...

Is Me!chargebackId a reference to a textbox containing a field (from the recordset) or an immediate reference to a field in the recordset?

Try Me.chargebackId
 
look what I found in Help:


You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around argumentlist. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.
To pass a whole array to a procedure, use the array name followed by empty parentheses.
 
Mile, I tried Me.chargebackId to no avail.

Ancient One I think you might be on to something! Part of that paragraph confuses me, though:

If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.

Does this mean if I use the function without the Call keyword it still discards the return value?

Also I wonder how I can call the function and assign it's return value without parens. "statusCode = cbStatus Me!chargebackId" throws a syntax error.

I'll play around with this some and get back, thanks!
 
does
StatusCode=Call cbstatus(Me!checkbackID)

work or your line without the quotes?
 
Nope, it says "expected expression" after Call.

The line I posted did not have quotes in the code either...
 
Try it again

Mile-0-Phile suggested that you try: CInt on the control, but you indicated that you knew it was an integer.

' Breaks on this line
statusCode = cbStatus(Me!chargebackId)

If this (Me!changebackId) is a control, it may be intepreted as a variant (see value in the help screen). That would give an error since you are sending a variant rather than an integer.

Try again:
statusCode = cbStatus(CInt(M!chargebackId))

Just a suggestion.
 
Hi fuzzygeek, as I indicated a few posts back I actually did try that out:

statusCode = cbStatus(CInt(Me!chargebackId))

With the exact same error. I've also tried variant and long for my types. Thanks for the reply though, I can use all the input I can get on this! :)
 
AncientOne said:
look what I found in Help:


You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around argumentlist. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.
To pass a whole array to a procedure, use the array name followed by empty parentheses.

Can you tell me where in the help file you found this?
 
in a97 help.

have you tried;

codestatus= Call(cbstatus Me!checkbackID)

Or as a last resort assign the function to a global variable and set statuscode to that variable. Then you can use:

Call cbStatus(Me!checkbackID)

statuscode=MyGlobal...
 
Okay, I was curious about looking at the entry but I can't find that in the help file (Access 2000).

I tried this:

codestatus= Call(cbstatus Me!checkbackID)

To no avail (still saying Expected: expression). I guess I could resort to using a global variable, it just seems wrong that I cannot get this to work. It's going to bug me to no end if I can't figure it out!! I may eventually have to use a global though, as I can't waste all my time on this problem. I really appreciate yours and Mile's help on this. If you have any other ideas keep 'em coming :)
 
Okay I created a new form with a button that ran the EXACT code in the sub on my last form. It works fine. MsgBox with the statusCode showing it's correct, no problems. This must have somethign to do with some other code in the form I was working on, I just don't know WHAT. I'll keep poking around here...
 
They hide any reference to the Call statement well in A2K help, but it's in Contents under Visual Basic Conceptual Topics, sub-heading Calling Sub and function procedures. And there it says if you are using the return value of a function you should enclose the arguments in parentheses.:confused: Confused? you will be!
 
Awesome, I found it thanks! Although, I don't think this has anything to do with my syntax or usage now. As I said, I created a new form, based on the same query, and used the exact same code as I posted to call the function, and it worked fine. I even removed the form module from the real form, and re-created the code again. Still no go.

Any possibility this is a bug somehow? I have no idea what else would be interfering here.
 

Users who are viewing this thread

Back
Top Bottom