4 of 4 people found this helpful
You can achieve this a few ways, depending on how much control you want the users to have over their search. If you'd like them to be able to search on other tag attributes in addition to the Descriptor, then I would recommend using a variation of Patrice's code sample above. If users should only ever search for keywords in the Descriptor field and all of the tags with the keyword should automatically be selected, then you should use the GetPointsSQL PI SDK method. Find the two VBA functions below for both situations:
Sub GetPointsByDescMask(desc_mask As String) 'Get tag list from Descriptor mask Dim ptlist As PointList Dim pt As PIPoint Set ptlist = PISDK.Servers.DefaultServer.GetPointsSQL("Descriptor Like '" & desc_mask & "'") 'Add points list to drop-down list ThisDisplay.tagResults.List = Array() For Each pt In ptlist ThisDisplay.tagResults.AddItem pt.Name Next pt End Sub Sub GetPointsBySearchDialog() 'Get tag list from tag search Dim ptlist As PointList Dim pt As PIPoint Dim search As New PISDKDlg.TagSearch 'Get points from the search dialogs Set ptlist = search.Show 'Add points list to drop-down list ThisDisplay.tagResults.List = Array() For Each pt In ptlist ThisDisplay.tagResults.AddItem pt.Name Next pt End Sub
For both methods, you'll need a ComboBox on the display (mine is named tagResults) to store the search results and a Search button to call the method.
For GetPointsByDescMask, you'll also need a text box on the display that stores the keyword (mine is named search_mask). When you press the Search button to call the method, you can extract the contents of the text box and pass it to GetPointsByDescMask:
Sub getpoints_Click() ThisDisplay.GetPointsByDescMask ThisDisplay.search_mask.Text End Sub
Here is a screenshot of my display using the GetPointsByDescMask method:
Hi Michael, thank you so much for the codes, this seems to be exactly what I was looking for.
Yes, the users will only Click the Check Box and it should return only the tags with the certain Keyword in the Descriptor field only.
So I guess, I can use the first code that you sent.
I will test it out and update later.
Thank you again Michael.
Hi Michael and Eugene,
Thank you both for your immediate responses.
I used your VBA Codes to get the required Tags (Tagname and Descriptor) with Specific Keywords and it worked wonderfully.
We typed in the Search Parameter directly into the Code as we the Users Click Button Options.
Here’s the code that I used.
Private Sub Get_Parameters_Click()
Dim atagnum As Long, count As Long, indice As Long
Dim ptlist As PointList
Dim pt As PIPoint
If ThisDisplay.CheckBox_SEB = True Then
Set ptlist = PISDK.Servers.DefaultServer.GetPointsSQL("Descriptor Like '*SEB WH PARA*'")
ListBox1.ColumnWidths = "150;400;"
count = 0
.ColumnCount = 2
For Each pt In ptlist
.List(count, 0) = pt.Name
.List(count, 1) = pt.PointAttributes("Descriptor")
count = count + 1
'bcount = count
Thank you so much Michael, Eugene and Ganesh.