bassnsjp
06-25-2009, 06:34 AM
Im using MS 2003 and Windows XP Pro. I don't have access to the PC that contains the VBA macro I'm writing so I will have to type an example. This is what I need to do:
Take a part number from the Required Inventory and attempt to locate it in the Available Inventory. Currently I do this by performing an InStr compare however, that sometimes finds an incorrect part number, but in fact the correct part number exists, but since the incorrect part number is encountered first it is used. Now, there are valid instances in which the Required part number is embedded in the Available part number, which is why I'm currently using InStr.
Now, to remedy the situation I'm thinking of performing a search in the Available Inventory using the StrComp function in attempt to locate part number strings that match dit for dit. If I don't find it then go back and perform the search again using InStr.
I was thinking of accomplishing this by building the string compare command and sending that to the search routine to use at the appropriate time.
strcmd = """StrComp(" & AvailPN "," & ReqdPN & ", " & "vbTextCompare)"
or
strcmd = """InStr(1, " & AvailPN "," & ReqdPN & ", " & "vbTextCompare)"
If strcmd = 0 then
do something
else
do something else
end if
Is it possible to build a command string? I haven't had much luck in getting this to work. Any assistance would be greatly appreciated, thanks in advance. :help
Steve
Take a part number from the Required Inventory and attempt to locate it in the Available Inventory. Currently I do this by performing an InStr compare however, that sometimes finds an incorrect part number, but in fact the correct part number exists, but since the incorrect part number is encountered first it is used. Now, there are valid instances in which the Required part number is embedded in the Available part number, which is why I'm currently using InStr.
Now, to remedy the situation I'm thinking of performing a search in the Available Inventory using the StrComp function in attempt to locate part number strings that match dit for dit. If I don't find it then go back and perform the search again using InStr.
I was thinking of accomplishing this by building the string compare command and sending that to the search routine to use at the appropriate time.
strcmd = """StrComp(" & AvailPN "," & ReqdPN & ", " & "vbTextCompare)"
or
strcmd = """InStr(1, " & AvailPN "," & ReqdPN & ", " & "vbTextCompare)"
If strcmd = 0 then
do something
else
do something else
end if
Is it possible to build a command string? I haven't had much luck in getting this to work. Any assistance would be greatly appreciated, thanks in advance. :help
Steve