0

I am using HP (Microfocus) Quality Center 12.5 and designed a button using the toolbar in Workflow.

The following code pulls the first value from the RecordSet but not all values. How do I pull all values from the RecordSet and display it?

Sub searchDefects()

  On Error Resume Next

    Dim a
     a = InputBox("Enter search query")

set TD1 = TDConnection
set com1 = TD1.command

com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%" 
&a &"%'"

set rec1 = com1.Execute

Dim i
DIM msg
msg = ""

rec1.First

 For i = 0 to rec1.RecordCount

     msg = msg & "," & rec1.FieldValue(i) & ","
     rec1.Next()

 Next

MsgBox msg

  On Error GoTo 0


End Sub
Harry
  • 1,233
  • 10
  • 24
Sohel
  • 656
  • 2
  • 11
  • 31

1 Answers1

0

I found a solution after trial and error but still don't know the reason behind the root cause and how it is solving it. Any feedback is appreciated.

Sub SearchDefectsDescription()
On Error Resume Next

Dim a
a = InputBox("Enter search query for Description field")

set TD1 = TDConnection
set com1 = TD1.command

com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%" &a &"%'"
set rec1 = com1.Execute

Dim i
DIM msg
msg = "Bug ID" & vbnewline
rec1.First

If a = vbCancel Then
MsgBox "Search is cancelled"
Exit Sub

ElseIf Len(a) = 0 Then
MsgBox "Search input is empty, plesea try again."
Exit Sub

Else
For i = 0 to rec1.RecordCount

msg = msg & rec1.FieldValue(0) & rec1.FieldValue(1) & " "
rec1.Next()
Next
End If

MsgBox msg

On Error GoTo 0
End Sub
Sohel
  • 656
  • 2
  • 11
  • 31