case statement

  • Thread starter Thread starter george
  • Start date Start date
G

george

I have the following code set in a module:
Function Rndratio(Rounding As String) As String


Dim Valuess As String

Select Case Rounding

Case "1.15"
Valuess = "1.2"
Case "1.25"
Valuess = "1.2"
Case "1.35"
Valuess = "1.4"
Case "1.45"
Valuess = "1.4"
Case "1.55"
Valuess = "1.6"
Case "1.65"
Valuess = "1.6"
Case "1.75"
Valuess = "1.8"
Case "1.85"
Valuess = "1.8"
Case "1.95"
Valuess = "2.0"
Case ""
Valuess = ""
Case Else
Valuess = "test"

End Select
Rndratio = Valuess



End Function

I would like to have the value of a bound
field "Rounding" to insert the value "Rndratio" in a
field named "Ratiornd".
I would apprecaite any help.
Thank you
 
Unless you're going to be changing this all of the time, I don't recommend
storing a value you can compute. Just call your function to compute the
value whenever you need it. This can be done in a calculated field in a
query or a calculated control on a form or report.
 
-----Original Message-----
Unless you're going to be changing this all of the time, I don't recommend
storing a value you can compute. Just call your function to compute the
value whenever you need it. This can be done in a calculated field in a
query or a calculated control on a form or report.

--
Wayne Morgan
MS Access MVP

The original calculations for the value in
the "Rounding" field are being done the way you suggested.
This value needs to be checked by the Function to give me
an Null or the value from the case statement. I then need
to check the "Ratiornd" field for Null or a value.
An IIf statement then chooses whether to use the
calculated value of the value in "Ratiornd".
This is being done to conform to rounding criteria that
does not conform to the norm.
Thanks,
George
 
Place a textbox on the form, hidden textbox if you wish. In the AfterUpdate
event of the textbox for Rounding, set the value of the new textbox to
Rndratio([Rounding]). The new textbox should be bound to the Ratiornd field
in the table.

Example:
Me.txtRndRatio = Rndratio(Me.txtRounding)

When the changes to the record are saved, the value in txtRndRatio will be
saved to Ratiornd in the table.
 
Thanks
-----Original Message-----
Place a textbox on the form, hidden textbox if you wish. In the AfterUpdate
event of the textbox for Rounding, set the value of the new textbox to
Rndratio([Rounding]). The new textbox should be bound to the Ratiornd field
in the table.

Example:
Me.txtRndRatio = Rndratio(Me.txtRounding)

When the changes to the record are saved, the value in txtRndRatio will be
saved to Ratiornd in the table.

--
Wayne Morgan
MS Access MVP


time,
I don't recommend function
to compute the
the "Rounding" field are being done the way you suggested.
This value needs to be checked by the Function to give me
an Null or the value from the case statement. I then need
to check the "Ratiornd" field for Null or a value.
An IIf statement then chooses whether to use the
calculated value of the value in "Ratiornd".
This is being done to conform to rounding criteria that
does not conform to the norm.
Thanks,
George


.
 
Back
Top