You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old November 24th, 2022, 09:28 AM   #1
Weo
Member
Sweden

Weo is offline
 
Join Date: Feb 2006
Location: Sweden
Posts: 82
WinCC Pro - msgFilterSQL

I'm little stucked and ask for small help from one with little more experience of vb script.

So, I have alarm control window Control1[Alarm control] which I need to filter when the screen is loaded. The filter is not constant but indirect (tagprefix).
As you see I added msgbox in end, and can confirm that the tagprefix is correct.

My script is like this today, but is not working:
(The script does work when I add my actual tagprefix as a constant i.e M1)
Guess there should be some wildcard around my prefix and I'm pretty close?

Sub OnGenerateScreen()
Dim prefix
prefix = Parent.Parent.Parent.TagPrefix

ScreenItems("Control1").MsgFilterSQL = "TEXT3 LIKE 'prefix' "

MsgBox prefix
End Sub
  Reply With Quote
Old November 24th, 2022, 11:25 AM   #2
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,889
The wildcard for some SQL versions is the percent symbol (%).


So [WHERE ]

Code:
TEXT3 LIKE 'prefix%'
would select records where the TEXT3 character field started with the string "prefix" e.g. TEXT3="prefix"; TEXT3="prefixXIFERP"; TEXT3="prefix_whatever"; etc.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
v) I probably have the highest ratio of forum posts to actual applications in the field (∞).
  Reply With Quote
Old November 24th, 2022, 01:57 PM   #3
Thomas_v2
Member
Germany

Thomas_v2 is offline
 
Join Date: Apr 2009
Location: Ger
Posts: 500
I think you just have to insert the string value of prefix, like:

ScreenItems("Control1").MsgFilterSQL = "TEXT3 LIKE '" & prefix & "'"

Maybe you have to escape the single quotes in VBscript.
  Reply With Quote
Old November 24th, 2022, 02:35 PM   #4
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 1,844
I think that it would be simply on vbs code



ScreenItems("Control1").MsgFilterSQL = "TEXT3 LIKE" & prefix


as your prefix is variable and you read it's data and add it to constant string.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Wincc rt pro to s7 1500 connection the18 LIVE PLC Questions And Answers 3 November 8th, 2021 04:06 AM
Multiplex tags in WINCC Pro v15.1 dahnuguy LIVE PLC Questions And Answers 24 September 29th, 2020 02:57 PM
WinCC RT Pro / WebNavigator V15.1 and SIMATIC Logon Hal9000 LIVE PLC Questions And Answers 0 July 3rd, 2019 12:46 PM
Citect Vs WinCC - Long Doug_Adam LIVE PLC Questions And Answers 22 October 3rd, 2014 02:56 PM
WINCC PRO V11 build problem with (0 errors, 0 warnings) Yessin LIVE PLC Questions And Answers 0 May 15th, 2013 03:14 AM


All times are GMT -4. The time now is 09:13 PM.


.