Need Help on ADODB Query, need to convert field to int and order on it

brusk

New Member
Joined
Oct 28, 2014
Messages
30
Guys, having an issue trying to get my query to order properly. Below is the working query but the problem is it's pulling the [Row] field in as text instead of an int so when it orders it it's not numerically correct. I've tried various things all of which gave me errors.

Code:
Call RunSQLQuery(ThisWorkbook.Name, "SELECT * FROM " & _                        "(SELECT S.[Alias], NW.[Host], HW.[Role], NW.[HostName], HW.[OS], HW.[CPU], HW.[Memory], HW.[HD1Drive], HW.[HD1Role], HW.[HD1Size], HW.[HD1SP], HW.[HD2Drive], HW.[HD2Role], HW.[HD2Size], HW.[HD2SP], HW.[HD3Drive], HW.[HD3Role], HW.[HD3Size], HW.[HD3SP], HW.[HD4Drive], HW.[HD4Role], HW.[HD4Size], HW.[HD4SP], HW.[HD5Drive], HW.[HD5Role], HW.[HD5Size], HW.[HD5SP], HW.[HD6Drive], HW.[HD6Role], HW.[HD6Size], HW.[HD6SP], HW.[HD7Drive], HW.[HD7Role], HW.[HD7Size], HW.[HD7SP], HW.[HD8Drive], HW.[HD8Role], HW.[HD8Size], HW.[HD8SP], [B]HW.[Row][/B] FROM [" & GetTableRange("cnfTableSystems") & "] S, [" & GetTableRange("cnfTable" & arProducts(iLoop1) & "Network") & "] NW, [" & GetTableRange("cnfTable" & arProducts(iLoop1) & "Hardware") & "] HW WHERE HW.[AssetID] = S.[AssetID] AND HW.[AssetID] = NW.[AssetID] AND HW.[Role] = NW.[Role] AND [B]CInt(HW.[Row]) = CInt(NW.[Row][/B]) [B]ORDER BY S.[Alias], HW.[Row])[/B] UNION " & _
                        "( SELECT S.[Alias], NW.[Host], HW.[Role], NW.[HostName], HW.[OS], HW.[CPU], HW.[Memory], HW.[HD1Drive], HW.[HD1Role], HW.[HD1Size], HW.[HD1SP], HW.[HD2Drive], HW.[HD2Role], HW.[HD2Size], HW.[HD2SP], HW.[HD3Drive], HW.[HD3Role], HW.[HD3Size], HW.[HD3SP], HW.[HD4Drive], HW.[HD4Role], HW.[HD4Size], HW.[HD4SP], HW.[HD5Drive], HW.[HD5Role], HW.[HD5Size], HW.[HD5SP], HW.[HD6Drive], HW.[HD6Role], HW.[HD6Size], HW.[HD6SP], HW.[HD7Drive], HW.[HD7Role], HW.[HD7Size], HW.[HD7SP], HW.[HD8Drive], HW.[HD8Role], HW.[HD8Size], HW.[HD8SP],[B] HW.[Row][/B] FROM [" & GetTableRange("cnfTable" & arProducts(iLoop1) & "Hardware") & "] HW, [" & GetTableRange("cnfTableSystems") & "] S, [" & GetTableRange("cnfTableAVPNetwork") & "] NW WHERE HW.[AssetID] = S.[AssetID] AND HW.[AssetID] = NW.[AssetID] AND HW.[Role] = NW.[Role] AND [B]CInt(HW.[Row]) = CInt(NW.[Row])[/B]) [B]ORDER BY S.[Alias], HW.[Row][/B]", arResults, True, False)

Thanks,
Bruce
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,221,590
Messages
6,160,666
Members
451,662
Latest member
reelspike

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