statement to remove everything after the first space in access query
Hello. I have a field (strength) that I just need the numbers at the beginning of the field and I want to strip off everything else. The numbers are not the same length.
Also - it is part of an Iff,then statement. The IIf then statement is working, I need to find a wat just to get the first numbers of the field - and put it in my iif statement. The Strength field is the one that I need that data stripped from.
Here is an example of the data
Strength:
1000 MG = 26.32 ML
200 MG = 5.26 ML
10 MG = 1 TAB
1 CAP = 1 CAP
I want it to look like this:
1000
200
10
1
Dose: IIf([PDM].[Strength] Is Null Or [PDM].[Strength_Unit] Is Null,[PDM].[Volume_Number],[PDM].[Strength])
if you want to use VAL(), you don't need the IIF() statement
Dose:Val([PDM.Strength_Unit])
is enough.. this will give the consecutive numerical values of the the field starting from position 1 and will stop when it finds a non numerical value
the last post of Jim should work.
awking00
Didn't read the original question properly and only addressed the conversion to number issue.
Assuming you want to return the volume_number if either strength or strength_unit is null and the numeric portion of the strength otherwise -
IIf([PDM].[Strength] Is Null Or [PDM].[Strength_Unit] Is Null,[PDM].[Volume_Number],Val(Left(InStr([PDM.Strength]," ")-1)))
The above assumes the strength will always begin with a number followed by a space. If it can exist as a stand alone number, add the test Iif(instr(strength,' ') > 0,Val(Left(InStr([PDM.Strength]," ")-1),[PDM.Strength]))
Dose:IIF(instr(Nz([Strengt
Jim.