function calls repeating...?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a handful of function calls (1 function called 3 times on its own,
and another function called - that's dependant on the first function). When
I run the query, I get prompted 6 times for the 1st function. How can I make
it so I only have to type in the 1st function one time?

My code is simple:

Public Function fvelfactor() As Single
fvelfactor = InputBox("Enter Velocity Factor to use for calculation", "Input
Required")
End Function

Public Function finvfactor(fvel As Single) As Single
finvfactor = 1 - (1 - fvel) / 2
End Function


My first function call in the query looks like this fvelfactor(), while the
call for my 2nd function looks like this finvfactor(fvelfactor()).

Thank you!
Derek
 
Do you really need a function?

You could just define a parameter in the query and produce a calculated
field using the built in facilities (I may have got the usage wrong).

something like:

SELECT 0.5-[enter velocity factor]/2 AS Answer, ....

in the design grid enter:
Answer: 0.5 - [enter velocity factor]/2
 
Thanks, David. I think I do actually need a function (some scoping issues
have come up - I was, for a brief while, able to use the parameters). I have
some VBA subs that build tables and append tables using the query about 30
times. If I use parameters, I have to enter the parameter value each and
every time.

So, yes, I (unfortunately) need the function. I'll be the only one in my
group using the database to perform the functions that I'm performing, so it
doesn't have to be elegant. The database already is generally streamlined
for the functionality we use about 95 - 98% of the time. It's that other 2 -
5% that's challenging.

Thanks!
Derek

David F Cox said:
Do you really need a function?

You could just define a parameter in the query and produce a calculated
field using the built in facilities (I may have got the usage wrong).

something like:

SELECT 0.5-[enter velocity factor]/2 AS Answer, ....

in the design grid enter:
Answer: 0.5 - [enter velocity factor]/2


Derek Wittman said:
I've got a handful of function calls (1 function called 3 times on its
own,
and another function called - that's dependant on the first function).
When
I run the query, I get prompted 6 times for the 1st function. How can I
make
it so I only have to type in the 1st function one time?

My code is simple:

Public Function fvelfactor() As Single
fvelfactor = InputBox("Enter Velocity Factor to use for calculation",
"Input
Required")
End Function

Public Function finvfactor(fvel As Single) As Single
finvfactor = 1 - (1 - fvel) / 2
End Function


My first function call in the query looks like this fvelfactor(), while
the
call for my 2nd function looks like this finvfactor(fvelfactor()).

Thank you!
Derek
 
Although... another thought crossed my mind.

Perhaps the UI will accept a value (number/single) and I can put the value
into a single field, single record table to HOLD it.

Then, I can reference that value in the query by a domain aggregate function
(sorry, no code yet - just considering the idea) recalling it, like dfirst or
dmax.

Sure, DA functions slow Access down, but then again, if there's only one
value to consider, it shouldn't slow it down that much, right?

What do you think?
Derek

David F Cox said:
Do you really need a function?

You could just define a parameter in the query and produce a calculated
field using the built in facilities (I may have got the usage wrong).

something like:

SELECT 0.5-[enter velocity factor]/2 AS Answer, ....

in the design grid enter:
Answer: 0.5 - [enter velocity factor]/2


Derek Wittman said:
I've got a handful of function calls (1 function called 3 times on its
own,
and another function called - that's dependant on the first function).
When
I run the query, I get prompted 6 times for the 1st function. How can I
make
it so I only have to type in the 1st function one time?

My code is simple:

Public Function fvelfactor() As Single
fvelfactor = InputBox("Enter Velocity Factor to use for calculation",
"Input
Required")
End Function

Public Function finvfactor(fvel As Single) As Single
finvfactor = 1 - (1 - fvel) / 2
End Function


My first function call in the query looks like this fvelfactor(), while
the
call for my 2nd function looks like this finvfactor(fvelfactor()).

Thank you!
Derek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top