Call function in data entry form

  • Thread starter Thread starter hermie
  • Start date Start date
H

hermie

Hello

Like to know if next is possible. When I start my data entry form, a textbox
shows # error. This is normal because no data have been entered yet. This
textbox call a function when some specific data in other fields are entered
it shows the calculated value. I like to have have that is the textbox is
blank or invisible till the required data is entered . Is this possible?

Herman
 
hermie said:
Hello

Like to know if next is possible. When I start my data entry form, a textbox
shows # error. This is normal because no data have been entered yet. This
textbox call a function when some specific data in other fields are entered
it shows the calculated value. I like to have have that is the textbox is
blank or invisible till the required data is entered . Is this possible?

Herman

Yep, you can use the IsError function. F'rinstance, if your text box's
control source is this:

=[FieldA] + [FieldB]

You could replace it with this:

=Iif(IsError([FieldA] + [FieldB]),"",[FieldA] + [FieldB])
 
Hi Brian Tnx for responding

I implemented your proposal in my form, however still have error in textbox

In first textbox I put: =IIf(IsError([puntos]/[valor]),"",[puntos]/[valor])
this works fine
in second textbox I put: =IIf(IsError([txtperc]),"",caltarea([txtperc])) and
this generated an #error instead of a blank field

do I something wrong?

Herman

Brian said:
hermie said:
Hello

Like to know if next is possible. When I start my data entry form, a textbox
shows # error. This is normal because no data have been entered yet. This
textbox call a function when some specific data in other fields are entered
it shows the calculated value. I like to have have that is the textbox is
blank or invisible till the required data is entered . Is this possible?

Herman

Yep, you can use the IsError function. F'rinstance, if your text box's
control source is this:

=[FieldA] + [FieldB]

You could replace it with this:

=Iif(IsError([FieldA] + [FieldB]),"",[FieldA] + [FieldB])
 
hermie said:
Hi Brian Tnx for responding

I implemented your proposal in my form, however still have error in textbox

In first textbox I put: =IIf(IsError([puntos]/[valor]),"",[puntos]/[valor])
this works fine
in second textbox I put: =IIf(IsError([txtperc]),"",caltarea([txtperc])) and
this generated an #error instead of a blank field

do I something wrong?

Herman

Yes, you did. Try this:

=IIf(IsError(caltarea([txtperc])),"",caltarea([txtperc]))
 
I tried that before and also shows an # error

Maybe there is something in the function that is shows the #error?

The function is:
Public Function caltarea(Pertar As String) As String

Select Case CDbl(Pertar) * 100
Case Is >= 90#
caltarea = "A"
Case Is >= 80# And Pertar < 90#
caltarea = "B"
Case Is >= 70# And Pertar < 80#
caltarea = "C"
Case Is >= 60# And Pertar < 70#
caltarea = "D"
Case Is < 60#
caltarea = "F"
Case Else
caltarea = "?"
End Select
End Function

Brian said:
hermie said:
Hi Brian Tnx for responding

I implemented your proposal in my form, however still have error in textbox

In first textbox I put: =IIf(IsError([puntos]/[valor]),"",[puntos]/[valor])
this works fine
in second textbox I put: =IIf(IsError([txtperc]),"",caltarea([txtperc])) and
this generated an #error instead of a blank field

do I something wrong?

Herman

Yes, you did. Try this:

=IIf(IsError(caltarea([txtperc])),"",caltarea([txtperc]))
 
hermie said:
I tried that before and also shows an # error

Maybe there is something in the function that is shows the #error?

The function is:
Public Function caltarea(Pertar As String) As String

Select Case CDbl(Pertar) * 100
Case Is >= 90#
caltarea = "A"
Case Is >= 80# And Pertar < 90#
caltarea = "B"
Case Is >= 70# And Pertar < 80#
caltarea = "C"
Case Is >= 60# And Pertar < 70#
caltarea = "D"
Case Is < 60#
caltarea = "F"
Case Else
caltarea = "?"
End Select
End Function

I think that, in this instance, I would forget about IsError and instead
modify the function to make sure that it never returns an error. Something
like this, perhaps:

Public Function caltarea(Pertar As Variant) As String

If IsNumeric(Pertar) Then
Select Case CDbl(Pertar) * 100
Case Is >= 90#
caltarea = "A"
Case Is >= 80# And Pertar < 90#
caltarea = "B"
Case Is >= 70# And Pertar < 80#
caltarea = "C"
Case Is >= 60# And Pertar < 70#
caltarea = "D"
Case Is < 60#
caltarea = "F"
Case Else
caltarea = "?"
End Select
Else
caltarea = ""
End If

End Function
 
Brian that was the problem
I copied the function and now it works

Thnxs a lot for your help

Herman
 
Back
Top