Check box to add 10%...

  • Thread starter Thread starter stephendeloach via AccessMonster.com
  • Start date Start date
S

stephendeloach via AccessMonster.com

In my form I have a check box "Expendable", when I check the check box I need
the "UnitPrice" to be multipled by 10%, if the check box isnt checked it
needs to be what the user enters, could someone tell me how to do this?
Thanks.
 
Private Sub Expendable_AfterUpdate()

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice), 0) * .1
End If

End Sub
 
I get a Compile Error: Syntax Error

Private Sub Expendable_AfterUpdate() ********************* is
highlighted

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice), 0) * .1 ************ is in red
End If

End Sub

That is in the VB editor...
 
OK after messing with it i got somewhere. This is what i have put in the
afterupdate..

Private Sub Expendable_AfterUpdate()

If Me!Expendable = True Then
Me!UnitPrice = UnitPrice + Nz(Me!UnitPrice) * 0.1
End If
End Sub

It works fine when I click the check box. Is there a way that I can uncheck
the checkbox and the UnitPrice go back to the original price? Thanks for the
fast reply.




I get a Compile Error: Syntax Error

Private Sub Expendable_AfterUpdate() ********************* is
highlighted

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice), 0) * .1 ************ is in red
End If

End Sub

That is in the VB editor...
Private Sub Expendable_AfterUpdate()
[quoted text clipped - 9 lines]
 
Is UnitPrice the name of the text box that contains the value you want to
multiply by .1?
That is how the code reads.
 
Is the name of your checkbox Expendable and the name of your textbox
UnitPrice, or are they something else?
 
Yes the names are UnitPrice (textbox) and Expendable (chk box)...
Is the name of your checkbox Expendable and the name of your textbox
UnitPrice, or are they something else?
I get a Compile Error: Syntax Error
[quoted text clipped - 22 lines]
 
This will give you 110% of the original number. Is that what you want?
Me!UnitPrice = Me!UnitPrice + Nz(Me!UnitPrice) * 0.1

I would write it a little differently. Also, notice the indention. Doesn't
it make it a little easier to read?

I had an idea you would want to do that.

Private Sub Expendable_AfterUpdate()

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice,0) * 1.1
Else
Me!UnitPrice = Nz(Me!UnitPrice,0) / 1.1
End If
End Sub

--
Dave Hargis, Microsoft Access MVP


stephendeloach via AccessMonster.com said:
OK after messing with it i got somewhere. This is what i have put in the
afterupdate..

Private Sub Expendable_AfterUpdate()

If Me!Expendable = True Then
Me!UnitPrice = UnitPrice + Nz(Me!UnitPrice) * 0.1
End If
End Sub

It works fine when I click the check box. Is there a way that I can uncheck
the checkbox and the UnitPrice go back to the original price? Thanks for the
fast reply.




I get a Compile Error: Syntax Error

Private Sub Expendable_AfterUpdate() ********************* is
highlighted

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice), 0) * .1 ************ is in red
End If

End Sub

That is in the VB editor...
Private Sub Expendable_AfterUpdate()
[quoted text clipped - 9 lines]
needs to be what the user enters, could someone tell me how to do this?
Thanks.
 
Works like a charm! Thanks!
This will give you 110% of the original number. Is that what you want?
Me!UnitPrice = Me!UnitPrice + Nz(Me!UnitPrice) * 0.1

I would write it a little differently. Also, notice the indention. Doesn't
it make it a little easier to read?

I had an idea you would want to do that.

Private Sub Expendable_AfterUpdate()

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice,0) * 1.1
Else
Me!UnitPrice = Nz(Me!UnitPrice,0) / 1.1
End If
End Sub
OK after messing with it i got somewhere. This is what i have put in the
afterupdate..
[quoted text clipped - 28 lines]
 
I get a Compile Error: Syntax Error

Private Sub Expendable_AfterUpdate() *********************
is highlighted

If Me!Expendable = True Then
Me!UnitPrice = Nz(Me!UnitPrice), 0) * .1 ************
is in red End If

End Sub

That is in the VB editor...

there is an unmatched parenthesis ")" in the line that's in red.
try
Me!UnitPrice = Nz(Me!UnitPrice, 0) * .1
 
Back
Top