FreerTool
asked on
Change my ASP Function
Public Function Logic
IF WarehouseID = 1 Then Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ARP" & ProductID
elseif
WarehouseID = 2 Then Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ELI" & ProductID
My current fuction is just
The table has both ProductID and WarehouseID
How would I go about doing this?
IF WarehouseID = 1 Then Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ARP" & ProductID
elseif
WarehouseID = 2 Then Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ELI" & ProductID
My current fuction is just
Public Function FormatTEDProductID (ProductID)
If Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ARP" & ProductID
End Function
The table has both ProductID and WarehouseID
How would I go about doing this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Getting error An error occurred on the server when processing the URL. Please contact the system administrator
with both and yes they are both integers.
with both and yes they are both integers.
post your updated code
I just stuck the code below in a blank asp page and got the appropriate results. If you're getting an error, it has to do with the values you're passing into the function
<%
Public Function FormatTEDProductID (ProductID, WarehouseID)
if not isNumeric( ProductID ) then
ProductID = 0
else
ProductID = CInt( ProductID )
end if
if not isNumeric( WarehouseID ) then
WarehouseID = 0
else
WarehouseID = CInt( WarehouseID )
end if
If WarehouseID = 1 and Len(ProductID) < 8 Then
ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ARP" & ProductID
elseif WarehouseID = 2 and Len(ProductID) < 8 Then
ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ELI" & ProductID
end if
End Function
Response.Write FormatTEDProductID( 4, 1 ) & "<br/></br>"
Response.Write FormatTEDProductID( 4, 2 )
%>
here it is:
pass WarehouseID , ProductID to the function...
Public Function FormatTEDProductID (WarehouseID , ProductID)
If Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = iif(WarehouseID = 1, "ARP", "ELI") & ProductID
End Function
pass WarehouseID , ProductID to the function...
ASKER
I think thats my problem is that i am not passing the warehouseID properly to the function.
<p class="listProductPartNumb er"><b>Pro duct Number:</b> <%=FormatTEDProductID(RsPr oduct("Pro ductID").V alue)%>
Is where I am Formatting my ProductID I am just trying to figure how i pass it to the function here.
<p class="listProductPartNumb
Is where I am Formatting my ProductID I am just trying to figure how i pass it to the function here.
use function i posted above with this:
<p class="listProductPartNumb er"><b>Pro duct Number:</b> <%=FormatTEDProductID(RsPr oduct("War ehouseID") .Value, RsProduct("ProductID").Val ue)%>
<p class="listProductPartNumb
remember, the function I posted above assumes, you have only 1 or 2 as WarehouseID
Logic is this: Add "ARP" if warehouse=1 or add "ELI" otherwise...
Logic is this: Add "ARP" if warehouse=1 or add "ELI" otherwise...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah i have troubleshoot some more but neither of your guys code is working for me. I must not be passing the WarehouseID properly. I get a blank white page when i update.
where is WarehouseID coming from, the recordset? can you confirm there is ALWAYS a WarehouseID in the data set coming back from the database?
if you hard code values in the function, does it work then?
if you hard code values in the function, does it work then?
this should work fine
<p class="listProductPartNumb er"><b>Pro duct Number:</b> <%=FormatTEDProductID(RsPr oduct("War ehouseID") .Value, RsProduct("ProductID").Val ue)%>
with this code
what do you get here?
Product Number: ??????
if you do not get any error, warehouseid is not coming from db correctly, o/w you get error!
try passing 1 as hardcoded value and try
<p class="listProductPartNumb er"><b>Pro duct Number:</b> <%=FormatTEDProductID(1, RsProduct("ProductID").Val ue)%>
<p class="listProductPartNumb
with this code
Public Function FormatTEDProductID (WarehouseID , ProductID)
If Len(ProductID) < 8 Then ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = iif(WarehouseID = 1, "ARP", "ELI") & ProductID
End Function
what do you get here?
Product Number: ??????
if you do not get any error, warehouseid is not coming from db correctly, o/w you get error!
try passing 1 as hardcoded value and try
<p class="listProductPartNumb
ASKER
so I am checking all my pages that have the warehouseID that i need to pass. for example.
http://www.automationrecovery.com/categories/Automation-Surplus/
http://www.automationrecovery.com/categories/Automation-Surplus/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it looks like product number is displaying properly as I see it shown in your page.
it looks like your link is not correct, can you post the code for it and what you expect to happen on the next page along with its code?
it looks like your link is not correct, can you post the code for it and what you expect to happen on the next page along with its code?
ASKER
sorry take a look at it now.
ASKER
Its working fine now, thanks for your assistance Big Monty
and what is the solution & why I did not get any share?
Public Function FormatTEDProductID (ProductID, WarehouseID)
if not isNumeric( ProductID ) then
ProductID = 0
else
ProductID = CInt( ProductID )
end if
if not isNumeric( WarehouseID ) then
WarehouseID = 0
else
WarehouseID = CInt( WarehouseID )
end if
If WarehouseID = 1 and Len(ProductID) < 8 Then
ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ARP" & ProductID
elseif WarehouseID = 2 and Len(ProductID) < 8 Then
ProductID = Right(String(8, "0") & ProductID, 8)
FormatTEDProductID = "ELI" & ProductID
end if
End Function