473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question For Microsoft Access Data Base

20 New Member
Question For Microsoft Access Data Base
--------------------------------------------------------------------------------

I am Trying to create a single formula that would do the following:

If A1 is less then or equal to 499, deliver B1*1, if A1 is equal to or less than 999 but more than and including 500, deliver B1*2, If A1 is equal to or less than 1499 but more than and including 1000, deliver B1*3, AND SO ON.....

I have read the Posts on this and they don't Work

=Int(A1/500)*B1 Dont work, It gives the wrong values for 500, 1000, 1500, etc

+Int(A1/500+1)-(MOD(A1,500)=0 Dont work, I cant get Access to except this formula. It wont save. It changes back to whatever was in the Control Source.

I am not an expert at this and the third response from what I can tell looks like an answer for Excel and not Access, Well I cant figure it out. Creating the Table which is the first part makes no since on how to do it.

That post was as follows:
[This followup was posted to microsoft.publi c.excel.workshe et.functions
with an email copy to =?Utf-8?B?QW1hbg==?=.
Please use the newsgroup for further discussion.]

Three possibilities, in addition to the option already discussed by
others, are below. None of the options requires the thresholds to be
equally spaced, nor that the return values be 1,2,3, etc.

1) Use the formula =B1*(IF(A1<=0,0 ,IF(A1<=500,1,I F(A1<=1000,2,3) )))
This might be the easiest to understand but it has two limitations.
First, IF statements can be nested only 7 deep. There are ways around
the limitation, but they just complicate the matter further. Second,
the thresholds and the returned values are hidden in the formula and
not immediately obvious from looking at the worksheet.

2) Create a table such as:
F G
2 0 1
3 500 2
4 1000 3

And, use the formula
Expand|Select|Wrap|Line Numbers
  1. =B1*INDEX(G2:G4,MATCH(A1,F2:F4,1)-(A1=INDEX(F2:F4,MATCH(A1,F2:F4,1))))
The 2nd part -- following the -( part -- is an adjustment for the fact
that you want the conditions to be 'less than or equal to'. The
advantage of this formula is that it is easy to adjust for more
conditions. The downside is that it might be somewhat intimidating to
a novice.

3) Use the VBA user defined function (UDF) given below as
=TieredPricing( F2:G4,A1,TRUE). The advantage is that it makes the
worksheet more 'self documented' and it further separates the code from
the data. The downside is the need for a VBA module and having to deal
with the accompanying 'This file contains macros' warning.
Expand|Select|Wrap|Line Numbers
  1. Function TieredPricing(LookupTable As Range, LookupValue As Double, _
  2. Optional IncludeBoundaryValue As Boolean = False)
  3. Dim Rslt As Variant
  4. On Error Resume Next
  5. Rslt = Application.WorksheetFunction.Match( _
  6. LookupValue, LookupTable.Columns(1), 1)
  7. If Not IsEmpty(Rslt) Then
  8. If IncludeBoundaryValue _
  9. And LookupTable.Cells(Rslt, 1).Value = LookupValue Then
  10. If Rslt = 1 Then _
  11. TieredPricing = _
  12. "Look up value outside of table values" _
  13. Else _
  14. TieredPricing _
  15. = LookupTable.Cells(Rslt - 1, 2).Value
  16. Else
  17. TieredPricing = _
  18. LookupTable.Cells(Rslt, 2).Value
  19. End If
  20. Else
  21. TieredPricing = "Look up value outside of table values"
  22. End If
  23. End Function
  24.  
None of this is working Please HELP

Joel
Jan 3 '10 #1
24 2955
RuralGuy
375 Recognized Expert Contributor
I would tend to create a Public Function in a standard module using a Select Case structure but you would have to finish the "AND SO ON" before code could be developed. It would be easier to understand and maintain later.
Jan 3 '10 #2
joeldault
20 New Member
Thanks For your responce. What you are telling me. I Cant seam to get the Public Funtion to cross tables
Jan 3 '10 #3
RuralGuy
375 Recognized Expert Contributor
If you are using this function in a form or query, I see no reason to cross tables. Are A and B in different tables? Do you have them joined in a query?
The Function I had in mind would take the two values and return one.
Jan 3 '10 #4
joeldault
20 New Member
This is what I am going.
I have a From That I am trying to calulate State and County transfer tax. The County Charges 3.75 Cents per 500 and The State Charges 1.10 per 500. The From I am Creating is addiing the Costs. If I record a Mortgage it is 14.00 for the First page and 3.00 for each additional Page. The Form I have been able to put different kinds of docs in and get it to some the total on the form, but when I put in that a house dols for lets say 10,000.00. It need to give me the total of $8.60. If there was a way to send you the form I would.
I had a public funtion working but it got to big and the program said i could not add more
This is what I had
Expand|Select|Wrap|Line Numbers
  1.  If "" & Me!Consideration < 499 Then
  2.  Me!ConsiderationCal = 1
  3.  Else
  4.  If "" & Me!Consideration < 1000 Then
  5.  Me!ConsiderationCal = 2
  6. Else
  7.  If "" & Me!Consideration < 1499 Then
  8.  Me!ConsiderationCal = 3
  9. Endif
  10. Endif
  11. Endif
after I got to 250000.00 The Computer said I could not enter more
Jan 3 '10 #5
joeldault
20 New Member
Sorry Thanks for at least looking. I have been working on this for three days. all day and night. I cant get it to work
Jan 3 '10 #6
nico5038
3,080 Recognized Expert Specialist
I would create a function like:

Expand|Select|Wrap|Line Numbers
  1. Function fncMultiplier(lngI As Long) As Long
  2.  
  3. fncMultiplier = 1
  4. While lngI > 500
  5.       fncMultiplier = fncMultiplier + 1
  6.       lngI = lngI - 500
  7. Wend
  8.  
  9. End Function
  10.  
Place this code in a module.

Now in the form field use:
Expand|Select|Wrap|Line Numbers
  1. =[B1] * fncMultiplier ([A1])
  2.  
Success,

Nic;o)
Jan 3 '10 #7
joeldault
20 New Member
I am sorry, The Funtion In the Public Code???, I have never done that before
Jan 3 '10 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Joel

Try the following function and see if it gives you the results you want.
Expand|Select|Wrap|Line Numbers
  1. Dim totalSum as Long 'the represents the total value (10,000 in your example)
  2. Dim i as Integer
  3. Dim count as Integer
  4. Dim rslt as Double
  5.  
  6.     For i=0 to totalSum Step 500
  7.         count = count +1
  8.     next i
  9.  
  10.     rslt = B1 * count ' should give you your result
Jan 3 '10 #9
joeldault
20 New Member
nico5038

That still seams to give off the wrong answer for 500, 1000, 1500 etc
Jan 3 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

17
6643
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products. So I shall have an Abstract Base called 'Car' implemented by Toyota, Ford, and Buick. Further I'd like to enable to client to say Car *factory;
18
7342
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated in MsAccess 97 or prior and have been converted to 2003. On occassion user 1 will open a db. When user 2 opens the db it will not let user 2 modify macros and what not. I can understand this and realize we could split the db; it is not worth ...
5
1464
by: Vai2000 | last post by:
Hi All, I am running into a concurrency problem. I have a worker process which reads some data out of a file and inserts fresh data into it. I have put a Monitor.Enter(this) and Monitor.Exit(this) on both of the routines which do read and writes. The worker process is spawned off by a Multithreaded application. I am seeing error in log which tells me that Description: Stack Trace- at System.IO.__Error.WinIOError(Int32 errorCode, String...
6
1770
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that the individual elements in an array of ImageList's could be identified by the ID, thereby allowing re-ordering the array without harm. A person could identify by index into the array, but that would not be preserved by re-ordering (and re-ordering...
8
3383
by: Ben R. | last post by:
Hi all, This is a multipart question. I’ve got an asp.net site that contains an access database. Previously, I would debug by making changes and uploading to my host. Now, I’d like to be able to debug locally and then deploy. I’d really like to use a relative path for the database file (so I could make no changes between hostide and debugging client side. When I try to use a relative path, it doesn’t seem to be referring to...
2
2388
by: Crimson* | last post by:
I've got a table with an entry type as "OLE Object" in Access 2003. In the form that the table is linked to I want to insert an image (BMP) for each record. However, when I attempt to do so the file is inserted and the filename (image.bmp) is inserted in the box with it taking up about half of the box. I didn't have this problem in Access XP. I've tried embedding and linking the file, but this always happens. Can anyone offer any...
7
4471
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears to be checking that the correct data type is used DataAcess sets an abstract class and methods
9
1502
by: Mike Hofer | last post by:
In a large application I'm working on (ASP.NET 1.1, VS2003), we have a base class that wraps stored procedures. Essentially, this base class (StoredProcedureBase) encapsulates the code to set up the connection, transaction, command and parameters required to invoke a stored procedure on our SQL Server database. It provides helper methods that simplify the process of invoking the stored procedure so that our data access classes can make the...
8
1623
by: =?ISO-8859-1?Q?Konrad_M=FChler?= | last post by:
Hi, I've a list of objects. I iterate the list and read the value of each object for many operation like: x = myList.value1 + myList.value2 etc. My question: Is it efficient to always use myList or should I get the pointer to
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.