Function to get rate

L

LillianH

I am new to VBA and I am trying to write a function for a Commission form.

The form has 9 controls. 8 are a combination of combo boxes and dollars
amounts. The user input determines what Commission % should be used to
calculate the commission. I am trying to build a function that will
generate the commission rate based on the user input. Do I have to have a
commission rate table or can I do a series of If..Then...Else statements in a
function using say a variable dCommRate. and give dCommRate a value based on
the other parameters chosen in the If then... I tryed a Select ...Case but
that seems to only work in a sub procedure? and it is my understanding that
sub procedures cannot return values. After the dCommRate variable is
determined I then need to multiply the dCommRate by the Sale and populate the
information in the underlying data table.

Is this doable?


Thanks
 
D

Douglas J. Steele

It's always a good idea to use a rate table for a number of reasons.

Select Case works in functions, though, so maybe you should post what you've
tried.
 
G

Guest

I need more information. What criteria is used to calculate commission. A
function is the correct route you are seeking. You would pass the criteria
to the function to get the desired commission.

Here is a simple example:

Public Function GetComm(Jobtitle)
Dim comm as Double
Selection Case Jobtitle
Case is = "Inside Sales Rep"
comm = 2.50
Case is = "Outside Sales Rep"
comm = 3.15
End Select
GetComm = Comm
End Public Function
 

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

Top