if value is non numeric then don't multiply..

mantis_sg

Board Regular
Joined
Nov 16, 2005
Messages
126
Hi,

I have a table with 3 end Columns (Qty, Weight and total) the total is calculated with the following SQL :

UPDATE tblWarehouse_stock SET Total = (Qty*Weight);

The problem is that these days it is possible to have the word "Part" replace the weight number value. Obviously this is causing problems. Is there a way in SQL to say if weight value is non-numberic then exit code? or does this have to be done via VBA? thanks a lot in advance.

Sean.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
To be honest it would be more advisable to not allow text entries into a field that should be holding numerical data - failing that I suppose you could use an Iif() statement along with a Value() statement to check for numerical data (haven't got time to check now but there may be an IsNumeric function you can use).

Cheers
Martin
 
Upvote 0
Cheers Martin,

After a bit more investigating I realise that the problem stated isn't the main problem, that issue was solved using the If() method in vba.

The real problem lies in my SQL code where I am combining columns with the same values, it has trouble doing it when "part" is used as the weight, it just lists the same data over and over but the qty is being doubled until it reaches a certain number (I'm assuming that this is the access cut off point to stop a loop). I am realy stumped :confused:
 
Upvote 0
I've used this generic SQL and it worked fine.


Expr1: IIf(IsNumeric([QTY])=True,[QTY]*[WEIGHT],"")

HTH,
CT Witter
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top