Check box to add 10%...

  • Thread starter stephendeloach via AccessMonster.com
  • 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.
 
D

Douglas J. Steele

Private Sub Expendable_AfterUpdate()

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

End Sub
 
S

stephendeloach via AccessMonster.com

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...
 
S

stephendeloach via AccessMonster.com

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]
 
K

Klatuu

Is UnitPrice the name of the text box that contains the value you want to
multiply by .1?
That is how the code reads.
 
D

Douglas J. Steele

Is the name of your checkbox Expendable and the name of your textbox
UnitPrice, or are they something else?
 
S

stephendeloach via AccessMonster.com

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]
 
K

Klatuu

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.
 
S

stephendeloach via AccessMonster.com

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]
 
B

Bob Quintal

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
 

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