I have the following piece of code. I am prompting the user for a Ship to code, then checking the code to make sure it is in the POSHPFIL_SQL. If the no records are returned I want a message to dispay "Ship To Not On file" and keep prompting the user. I realize I need some sort of loop but I am new to VB and can't seem to figure out the logic.
ShipTo = InputBox(Message2, Title2, "",100, 100)
strSQL10 = "Select ship_to_cd from POSHPFIL_SQL where ship_to_cd = '" & ShipTo & "'"
set rs10=createobject("ADODB.Recordset")
with rs10
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL10
End with
if rs10.recordcount = 0 then
Wscript.Echo "Ship To Not on File"
ShipTo = InputBox(Message2, Title2, "",100, 100)
set rs10=createobject("ADODB.Recordset")
with rs10
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL10
End with
end if
ShipTo = InputBox(Message2, Title2, "",100, 100)
strSQL10 = "Select ship_to_cd from POSHPFIL_SQL where ship_to_cd = '" & ShipTo & "'"
set rs10=createobject("ADODB.Recordset")
with rs10
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL10
End with
if rs10.recordcount = 0 then
Wscript.Echo "Ship To Not on File"
ShipTo = InputBox(Message2, Title2, "",100, 100)
set rs10=createobject("ADODB.Recordset")
with rs10
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL10
End with
end if