VB Functions

Nenya

Registered User.
Local time
Today, 22:53
Joined
Jul 4, 2003
Messages
20
This could be an easy question...

I created a vb funtion to output a string. I want to use this function on a report.
How do i use the function in a report?
 
In the controlsource of a textbox (for example) set it to

=YourFunctionName(Function Arguments)
 
how do you want to use it on a report, is it in a text box, if so then set the textbox property ControlSource equal to "=MyFunction" and as long as the function is designed to return a string then this will work.

example of function in a basic module:
Code:
Public Function MyFunction() As String
    dim strNewData as String
    strNewData = "Test String from MyFunction"
    MyFunction = strNewData
End Function
 
I tried your function... it works.
So i guess the problem is in my function parameters.

=CoutTotal([Txt_Cout1].Texte, [TxtCout2].Texte, [TxtCout3].Texte, [TxtCout4].Texte, [TxtCout5].Texte, [TxtCout6].Texte)

This is in my ControlSource property (of a textbox)

Is it correct??

(btw, i use a french version of access)
 
The .Texte (.Text) could be the problem as there is a difference between .Text and .Value and what you really want is the .Value which is the default if you don't reference it.

and because it's a report, try using the memory names instead of the control names like the following;
Code:
=CoutTotal(me![Txt_Cout1], me![TxtCout2], me![TxtCout3], me![TxtCout4], me![TxtCout5], me![TxtCout6])

sorry, the only french i know will get me slapped across the face :D
 
Last edited:
Still not working :(

The "me" is not accepted. I think it works only within vb code.

I can do functions that works fine as long as i have less than two parameters. If i have 2, access is unhappy (so i am).

Any ideas?

oh... and...

sorry, the only french i know will get me slapped across the face

uh?
 
=CoutTotal([Txt_Cout1], [TxtCout2], [TxtCout3], [TxtCout4], [TxtCout5], [TxtCout6])

No?
 
Thx for the help!!!!
It's working now!!!

I used the text property tho:rolleyes:
 

Users who are viewing this thread

Back
Top Bottom