Function getLevels(inPart As String) As String
On Error GoTo myErr
Dim rs As New ADODB.Recordset
Dim strCat As String
strCat = ""
Dim selectCommand As String
selectCommand = "SELECT DISTINCT [Core Sand Type] as CST FROM tblCbxNumberData WHERE PartN = " & """" & inPart & """"
rs.Open selectCommand, CurrentProject.Connection
'Get the types
Do While rs.EOF = False
strCat = strCat & rs("CST") & "/"
rs.MoveNext
Loop
rs.Close
If Len(strCat) > 0 Then
'Reorder if needed
If InStr(1, strCat, "Expert/") >= 1 Then
strCat = Replace(strCat, "Expert/", "")
strCat = "Expert/" & strCat
End If
'Remove the last slash
strCat = Left(strCat, Len(strCat) - 1)
End If
getLevels = strCat
Exit Function
myErr:
getLevels = strCat
End Function
Function getLocations(inPart As String) As String
On Error GoTo myErr
Dim rs As New ADODB.Recordset
Dim strCat As String
strCat = ""
Dim selectCommand As String
selectCommand = "SELECT DISTINCT [Loc] as CST FROM tblCbxNumberData WHERE PartN = " & """" & inPart & """"
rs.Open selectCommand, CurrentProject.Connection
'Get the types
Do While rs.EOF = False
strCat = strCat & rs("CST") & "/"
rs.MoveNext
Loop
rs.Close
If Len(strCat) > 0 Then
'Remove the last slash
strCat = Left(strCat, Len(strCat) - 1)
Else
strCat = "" 'replaced NoValue
End If
getLocations = strCat
Exit Function
myErr:
MsgBox Err.number & " - " & Err.Description 'add this line in getLocations function
getLocations = strCat
End Function
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE