Solved

if...then

Posted on 1998-09-16
8
409 Views
Last Modified: 2008-02-26
ok, I'm totally lost when it comes to programming access. So
   here's what seems so simple but doesn't work for me.  (Access 97): Let's keep it
   simple.  I have 3 fields on a form (from a table). The fields are "subtotal", "tax", and
   "total".  The "tax" field is a check box (yes/no). My expression in the "total" field
   states:  Iff([tax]="yes",[total]=(.07*[subtotal]),
   [total]=[subtotal])
I'm getting to old for this.  Basic was easy for me, this is not.
J. Hinely
0
Comment
Question by:jrhinely
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Expert Comment

by:Willtry
ID: 1962567
I am no expert by any stretch, but I don't think you want to use an immediate If statement in your example, I would think that you would use an If then statement. Instead of using the expression builder, try using the code builder.

If([Tax]="yes", then
   [Total]= 0.07*[Subtotal]

I think this might work for you.

0
 
LVL 7

Accepted Solution

by:
jconde earned 50 total points
ID: 1962568
Mabe this code will help you out.
If you have any problems please let me know about it!

Private Sub Tax_Click()
  If Tax = -1 Then             'Tax is checked
    Total =  0.07*[subtotal]
  Else
    Total = Subtotal
  End If
End Sub


Jconde
0
 

Expert Comment

by:TerryEllis
ID: 1962569
Try it like this  IIF([tax],[total]=(1.07*[subtotal]),[total]=[subtotal])
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 5

Expert Comment

by:tuvi
ID: 1962570
You don't need the [total]= part. Try this:

IIf([tax],(1.07*[subtotal]),[subtotal])
0
 
LVL 1

Expert Comment

by:toys032498
ID: 1962571
Great peace of code Tuvi and TerryEllis, I forgot all about IIF, thanks for the reminder.
0
 

Expert Comment

by:TerryEllis
ID: 1962572
tuvi, your right on about not needing the "[total] = part". Thank you for the correction.
0
 

Author Comment

by:jrhinely
ID: 1962573
Thanks, guys.  I wish I could award all of you some points.  Actually "tuvi" had what I used.
0
 
LVL 7

Expert Comment

by:jconde
ID: 1962574
Guess tuvi deserves the points uhhh!

Tuvi, I'll post an answer worth 50 points so you can get them!

Later
Jorge
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question