Hi,
I am reading the contents of a list box that contains computer names obtained from a .ldb file.
I split the string and then perform a dlookup on each computer name to get the person's name who is in the database:
Dim StrSql,strsql12 As String
Dim varInstTypes As Variant
Dim varInst0, varInst1, varInst2 As String
Dim User0, User1, User2 As String
StrSql = Me.lstLockFileContents.RowSource
strsql12 = Trim(strsql12)
varInstTypes = Split(strsql12, " ") 'Split the string using space delimiters
If IsEmpty(varInstTypes(0)) = True Then
'If varInstTypes(0) = "" Then
varInst0 = "None"
Else:
varInst0 = varInstTypes(0)
User0 = DLookup("[UserName]", "tblUserName", "[computername] = '" & varInst0 & "'")
strsql12 = User0 & ";"
End If
' ...and so on
Me.lstNamesOnly.RowSource = strsql12
The problem I am having is stopping the building of the string when I reach a VarInst that contains nothing and get the subscript out of range error. I have tried trapping it with an if err.number = 9 then resume next but that is not working.
How is this properly handled?
Thanks, Dan
I am reading the contents of a list box that contains computer names obtained from a .ldb file.
I split the string and then perform a dlookup on each computer name to get the person's name who is in the database:
Dim StrSql,strsql12 As String
Dim varInstTypes As Variant
Dim varInst0, varInst1, varInst2 As String
Dim User0, User1, User2 As String
StrSql = Me.lstLockFileContents.RowSource
strsql12 = Trim(strsql12)
varInstTypes = Split(strsql12, " ") 'Split the string using space delimiters
If IsEmpty(varInstTypes(0)) = True Then
'If varInstTypes(0) = "" Then
varInst0 = "None"
Else:
varInst0 = varInstTypes(0)
User0 = DLookup("[UserName]", "tblUserName", "[computername] = '" & varInst0 & "'")
strsql12 = User0 & ";"
End If
' ...and so on
Me.lstNamesOnly.RowSource = strsql12
The problem I am having is stopping the building of the string when I reach a VarInst that contains nothing and get the subscript out of range error. I have tried trapping it with an if err.number = 9 then resume next but that is not working.
How is this properly handled?
Thanks, Dan