To calculate fields that have 'Number' & 'Text' datatype.

N

NJ

I am trying to calculate a form entry where some of the fields values have
'Number' datatype while some have 'Text datatype.
 
J

Jerry Whittle

In your text field, is the data always numerals or are there some ABCs in it
also?

A representative sample of the data and what you are trying to do would help
us to help you.
 
J

John W. Vinson

I am trying to calculate a form entry where some of the fields values have
'Number' datatype while some have 'Text datatype.

You can use the Val() function to convert a text string containing a number to
an actual numeric value: e.g.

Val("123") = 123
Val("35ABC") = 35

But be warned:

Val("ABC123") = 0 (since it's not a leading number)
Val("123E4ABC") = 1230000 (the E4 is interpreted as scientific notation)
 
N

NJ

Thank for your eamil:

The text field is a free form entry textbox where users can enter either 1
or 0 or N/A; but if I do the calculation; then it's the problem, as in the
other free form textboxes users are allowed to enter only either 1 or 0.

The form is something like the below:

Trb_Summy Trb_Desc CTI CC Vendor
Outage Score
(only 1 or 0) (only 1 or 0) (only 1 or 0)(only 1 or 0)(only 1 or 0 or N/A)
(only 1 or 0 or N/A)

The Score is the calculated field where I use the below formula:

Private Sub Score_KeyDown(KeyCode As Integer, Shift As Integer)
If (Outage = "N/A") Or (Vendor_Tab = "N/A") Then
Score.Value = (((Trb_Summy + Trb_Desc + CTI + CC + Vendor + Outage) / 9) *
100)
Else
Score.Value = (((Trb_Summy + Trb_Desc + CTI + CC + Vendor + Outage) / 10) *
100)
End If
End Sub
 
N

NJ

Thank for your eamil; actually I am trying to do the below:

The text field is a free form entry textbox where users can enter either 1
or 0 or N/A; but if I do the calculation; then it's the problem, as in the
other free form textboxes users are allowed to enter only either 1 or 0.

The form is something like the below:

Trb_Summy Trb_Desc CTI CC Vendor
Outage Score
(only 1 or 0) (only 1 or 0) (only 1 or 0)(only 1 or 0)(only 1 or 0 or N/A)
(only 1 or 0 or N/A)

The Score is the calculated field where I use the below formula:

Private Sub Score_KeyDown(KeyCode As Integer, Shift As Integer)
If (Outage = "N/A") Or (Vendor_Tab = "N/A") Then
Score.Value = (((Trb_Summy + Trb_Desc + CTI + CC + Vendor + Outage) / 9) *
100)
Else
Score.Value = (((Trb_Summy + Trb_Desc + CTI + CC + Vendor + Outage) / 10) *
100)
End If
End Sub
 
N

NJ

Actually the Val function works.

Thanks

John W. Vinson said:
You can use the Val() function to convert a text string containing a number to
an actual numeric value: e.g.

Val("123") = 123
Val("35ABC") = 35

But be warned:

Val("ABC123") = 0 (since it's not a leading number)
Val("123E4ABC") = 1230000 (the E4 is interpreted as scientific notation)
 

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