AndJH
Member
Hello everyone,
I'm having difficulty writing data to a TagGroup item in VBA. I'm pulling values from a SQL Express database and attempting to write the string value to a string tag. I'm new to VBA and FT View SE, and any help would be greatly appreciated. The problem lies in writing the variable PLCTestTag value to the TagGroup.Item object.
The code I am working with:
I'm having difficulty writing data to a TagGroup item in VBA. I'm pulling values from a SQL Express database and attempting to write the string value to a string tag. I'm new to VBA and FT View SE, and any help would be greatly appreciated. The problem lies in writing the variable PLCTestTag value to the TagGroup.Item object.
The code I am working with:
Code:
Public MyTagGroup As TagGroup
Private Sub Display_AnimationStart() 'Creates tag group on display load to build object and put into scan
If MyTagGroup Is Nothing Then 'Checks for existence of tag group
Set MyTagGroup = Application.CreateTagGroup(Me.AreaName, 500)
MyTagGroup.Add "{[PLC]PALLET_ID[0]}"
End If
End Sub
Private Sub btnLookup_Released()
'Declare variables
Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordSet = New ADODB.Recordset
Dim PLCTestTag As String
'Open Connection
objMyConn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=user;Initial Catalog=PALTAG;Data Source=USER-PC\SQLEXPRESS"
objMyConn.Open
'Set and Excecute SQL Command
Set objMyCmd.ActiveConnection = objMyConn
objMyCmd.CommandText = "Select SKUMASTER.UCC From SKUMASTER"
objMyCmd.CommandType = adCmdText
objMyCmd.Execute
'Open Recordset
Set objMyRecordSet.ActiveConnection = objMyConn
objMyRecordSet.Open objMyCmd
'Copy Data to Tags
PLCTestTag = objMyRecordSet.GetString(adClipString)
MyTagGroup.Item("{[PLC]PALLET_ID[0]}") = PLCTestTag
'Close Connection
objMyConn.Close
End Sub