Hi,
I have a query and one of the fields in this query is as such:
Total: [PURPRI]*[ORDQTY]-[DISCNT]
The data type for the field [DISCNT] is a string (even though the field contains a number). For 10 out of the few thousand records, someone has entered in multiple spaces (ie: " ") in the fields. I don't know why they would do that, but it produces an error and when I export into excel, it exports it out without a total for those records. Is there a way I can tell Access to not subtract anything if [DISCNT] is not a number?
Thanks in advance,
Raza
9 1165
Oh yeah, and I don't have control over the database, it is located on a server and I don't have access to change anything. I can only pull data from it, so I can't go in and change the data type for the problem field.
FishVal 2,653
Recognized Expert Specialist
Hi, Raza.
Not sure whether it will work if you run the query from Excel, but anyway try the following
[PURPRI]*[ORDQTY]-Val([DISCNT])
NeoPa 32,557
Recognized Expert Moderator MVP
Oh yeah, and I don't have control over the database, it is located on a server and I don't have access to change anything. I can only pull data from it, so I can't go in and change the data type for the problem field.
Definitely a good point to add there Raza ;)
BTW does your discount apply only the once per order as coded, or should it apply to each unit? If the latter then you will need to rearrange things somewhat as : - [ORDQTY] * ([PURPRI] - Val([DISCNT]))
Definitely a good point to add there Raza ;)
BTW does your discount apply only the once per order as coded, or should it apply to each unit? If the latter then you will need to rearrange things somewhat as : - [ORDQTY] * ([PURPRI] - Val([DISCNT]))
Reading up on the Val() function, I believe this is what i need. Thank you for the help.
NeoPa 32,557
Recognized Expert Moderator MVP
No problem.
Glad I was able to.
BTW - DID your formula need to apply discount per line?
You were right. I mapped this from an existing crystal report that was created before I got here into access and now that you mentioned it, it did look off. I assumed too much when I did that.
The DISCNT is a percentage discount off the unit price. So now I have: - IIf(IsNull([DISCNT]), [PURPRI]*[ORDQTY], [PURPRI]*((100-Val([DISCNT]))/100)*[ORDQTY])
NeoPa 32,557
Recognized Expert Moderator MVP
Try instead : - [ORDQTY]*[PURPRI]*(100-Val(Nz([DISCNT],'0')))/100
yes, that's good too. I suppose it is cleaner.
I actually never bothered to look up what Nz() actually does until now, though I knew it existed. I would just usually "IIF" my way out of the situation.
NeoPa 32,557
Recognized Expert Moderator MVP
In situations like this Nz() is much cleaner and easier to understand logic-wise.
Glad it helped anyway :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: G |
last post by:
Hello,
I would like look at a user-entered string, and copy all characters starting
from the left until a number is found. As soon as a number is detected, the
copy should stop and the...
|
by: THEAF |
last post by:
My form is for entering data about centres. Data like Centre name, number, address. i have 5 command buttons on this form
* Add new File
* Delete File
* Reset
*Clear
*Update
Im using this...
|
by: =?Utf-8?B?Sm9uYXRoYW4gU21pdGg=?= |
last post by:
I have written a service, but it won't stop, Eventvwr reports the following:
"Failed to stop service"
The code is as follows:
============================================
Protected Overrides...
|
by: ravindarjobs |
last post by:
hi......
i am using ms access 2003,vb6
i have a form.
in that i have 2 buttons
1. start search
2 stop search
when i click the "start search" button the fucntion SearchSystem() is called,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |