473,498 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stop Access from multipying a string that's not a number.

53 New Member
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
Sep 28 '07 #1
9 1165
RZ15
53 New Member
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.
Sep 28 '07 #2
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])
Sep 28 '07 #3
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 :
Expand|Select|Wrap|Line Numbers
  1. [ORDQTY] * ([PURPRI] - Val([DISCNT]))
Sep 29 '07 #4
RZ15
53 New Member
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 :
Expand|Select|Wrap|Line Numbers
  1. [ORDQTY] * ([PURPRI] - Val([DISCNT]))
Reading up on the Val() function, I believe this is what i need. Thank you for the help.
Oct 3 '07 #5
NeoPa
32,557 Recognized Expert Moderator MVP
No problem.
Glad I was able to.

BTW - DID your formula need to apply discount per line?
Oct 3 '07 #6
RZ15
53 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([DISCNT]), [PURPRI]*[ORDQTY], [PURPRI]*((100-Val([DISCNT]))/100)*[ORDQTY])
Oct 3 '07 #7
NeoPa
32,557 Recognized Expert Moderator MVP
Try instead :
Expand|Select|Wrap|Line Numbers
  1. [ORDQTY]*[PURPRI]*(100-Val(Nz([DISCNT],'0')))/100
Oct 3 '07 #8
RZ15
53 New Member
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.
Oct 5 '07 #9
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 :)
Oct 5 '07 #10

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

Similar topics

3
1469
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...
2
1709
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...
5
2185
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...
4
2497
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,...
0
7004
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...
0
7167
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,...
0
7208
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...
0
7379
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...
0
3095
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
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...

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.