Trying to use a function to fill a text box

rap1971

Registered User.
Local time
Today, 17:33
Joined
Jan 16, 2001
Messages
23
I posted this in the Modules section...thought I'd put it in here, too...

I have two text boxes...T1 and T2...I am trying to send the contents of these text boxes to a function CostFactor and return a value into a third text box, T3. The function is declared and coded in a module in the same database. The code compiles and appears to be correct. I set teh control source of T3 to
=CostFactor([T1],[T2])
When I run the form I get ?#Name in the T3 text box...
What am I doing wrong?
SOS

**No one expects the Spanish Inquisition**
 
The reason why this does not work is because T3 is waiting for some event before it shows a value.

Why don't you try this then incorporate it to how you want it to look.

You have T1 ,T2 and T3 respectively, now have a command button called let's say Calculate.

When the user clicks on the command button
it will run the on_click event procedure for that command button.

Within the on_click event procedure you can enter the following code:

T3.Value = CostFactor(T1.Value, T2.Value)


------

The reason why you are seeing #Name in the T3 text box is because it cannot find a field called =CostFactor([T1],[T2])

----- Hope this helps

tc3of4
 
I just tried that...I get an error message that says:

Cannot find the macro 'T3'...

agh!
 
I just reviewed my book...Access 2000 Programming...
You can reference a declared function directly from a control source within a text box. Something else must be wrong.

Could it be that one of the text boxes is manually filled in and the other is filled in as part of an After-Update line of code that pulls a value from a combo box?
 
If you want, you can e-mail it to me and I can take a look at it.

I was assuming that you had 3 text boxes and you want the values of the first 2 displayed in the 3rd one (after they have been through the CostFactor function)

Just wondering, do you enter values within the two text boxes, or are they updated when a certain action has been completed.

tc3of4
 
The first text box is entered by the user.
The second is filled in with an After Update line of code where the third column of a combo box is displayed in this box.

I then take these two text boxes and use them as the arguments to pass to my CostFactor function.

I'll email it to you. If you can look at it I'd appreciate it.

I watered it down to try and figure out where my code is falling apart.
 
The problem is with the array...not the function.

I need help with declaring, populating and using multidimensional arrays.
 
I just tested it out and it seems to work fine. You declared it, and populated properly...

tc3of4

There was an a little syntax error with the coding though, --- it's with your Select Case part...
I'm sending you mail that will explain

[This message has been edited by tc3of4 (edited 01-18-2001).]
 

Users who are viewing this thread

Back
Top Bottom