Default Value calculation

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

Guest

I have a text box "totalamt" and a text box "depamt". I would like the
default value of "depamt" to be half of the "totalamt". I attempted on the
after focus event on the totalamt text box to program a statement. However,
since I'm not a programmer it obviously didn't work. This is the statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I have no
clue. Can someone help.

Thanks.
 
Wow ... that's a true "Duh" moment.

However, I changed my slash to a divide and I now getting a run time error
stating that the value I entered isn't valid.


Paul said:
It looks like you used the wrong slash "\" instead of "/" in the Me.DepDue =
line.

margaret said:
I have a text box "totalamt" and a text box "depamt". I would like the
default value of "depamt" to be half of the "totalamt". I attempted on
the
after focus event on the totalamt text box to program a statement.
However,
since I'm not a programmer it obviously didn't work. This is the
statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I have
no
clue. Can someone help.

Thanks.
 
What happens when you take out the quotes around [Me.TotalAmt] / 2 ?

margaret said:
Wow ... that's a true "Duh" moment.

However, I changed my slash to a divide and I now getting a run time error
stating that the value I entered isn't valid.


Paul said:
It looks like you used the wrong slash "\" instead of "/" in the
Me.DepDue =
line.

margaret said:
I have a text box "totalamt" and a text box "depamt". I would like the
default value of "depamt" to be half of the "totalamt". I attempted on
the
after focus event on the totalamt text box to program a statement.
However,
since I'm not a programmer it obviously didn't work. This is the
statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I
have
no
clue. Can someone help.

Thanks.
 
It gives me the error "can't find the field "|" referred to in your expression.

Paul said:
What happens when you take out the quotes around [Me.TotalAmt] / 2 ?

margaret said:
Wow ... that's a true "Duh" moment.

However, I changed my slash to a divide and I now getting a run time error
stating that the value I entered isn't valid.


Paul said:
It looks like you used the wrong slash "\" instead of "/" in the
Me.DepDue =
line.

I have a text box "totalamt" and a text box "depamt". I would like the
default value of "depamt" to be half of the "totalamt". I attempted on
the
after focus event on the totalamt text box to program a statement.
However,
since I'm not a programmer it obviously didn't work. This is the
statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I
have
no
clue. Can someone help.

Thanks.
 
I would think that Me.[TotalAmt]/2 would work. Try it without or without
the quotes. I thought the quotes were just for strings.

margaret said:
It gives me the error "can't find the field "|" referred to in your
expression.

Paul said:
What happens when you take out the quotes around [Me.TotalAmt] / 2 ?

margaret said:
Wow ... that's a true "Duh" moment.

However, I changed my slash to a divide and I now getting a run time
error
stating that the value I entered isn't valid.


:

It looks like you used the wrong slash "\" instead of "/" in the
Me.DepDue =
line.

I have a text box "totalamt" and a text box "depamt". I would like
the
default value of "depamt" to be half of the "totalamt". I attempted
on
the
after focus event on the totalamt text box to program a statement.
However,
since I'm not a programmer it obviously didn't work. This is the
statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I
have
no
clue. Can someone help.

Thanks.
 
Paul:

It turned out to be another "Duh" moment. The control's name was "DepAmt"
not "DepDue". I've posted the procedure that worked so it someone else reads
this, they'll have the answer.

Thanks for your help.

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > 0 Then
Me.DepAmt = Me.TotalAmt / 2
Else
Me.DepAmt = "0"

End If

End Sub


Paul said:
I would think that Me.[TotalAmt]/2 would work. Try it without or without
the quotes. I thought the quotes were just for strings.

margaret said:
It gives me the error "can't find the field "|" referred to in your
expression.

Paul said:
What happens when you take out the quotes around [Me.TotalAmt] / 2 ?

Wow ... that's a true "Duh" moment.

However, I changed my slash to a divide and I now getting a run time
error
stating that the value I entered isn't valid.


:

It looks like you used the wrong slash "\" instead of "/" in the
Me.DepDue =
line.

I have a text box "totalamt" and a text box "depamt". I would like
the
default value of "depamt" to be half of the "totalamt". I attempted
on
the
after focus event on the totalamt text box to program a statement.
However,
since I'm not a programmer it obviously didn't work. This is the
statement:

Private Sub TotalAmt_AfterUpdate()

If Me.TotalAmt > "0" Then
Me.DepDue = "[Me.TotalAmt] \ 2"
Else
Me.DepDue = "0"
End If

End Sub

I'm guessing it's my [me.totalamt]/2 that's not working, however, I
have
no
clue. Can someone help.

Thanks.
 
Back
Top