WinnCC Flexible code question

smcmanus

Member
Join Date
Jan 2006
Location
Vancouver
Posts
109
The code below is all in one script called by the main screen. I have 2 buttons. Move record forward and move Record Previous. What i need to do is call a script "MoveForward" with the move forward button and call another script "Move Previous" with the move previos button. But how to I pass my record set object "rst"? see code below! The issue I am having is I am stuck in a do until loop therefore it is not allowing me to click any objects on my screen. i.e move forward and move previos buttons. That's why if maybe I can call 2 different scrips up with passing the recordset it may be easier.





Dim conn,rst
Dim SQL_Table

Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=c:\G&S.mdb"

rst.CursorLocation = 3
rst.CursorType = 3
rst.LockType = 3

SQL_Table = "Select * FROM tblData1"

rst.open SQL_Table,conn



Do Until strscreen <> HmiRuntime.BaseScreenName

SmartTags("LASER_2D") = rst.Fields(0).Value
SmartTags("LASER_2D_GRADE") = rst.Fields(1).Value
SmartTags("G&S_2D") = rst.Fields(2).Value


Do While SmartTags("btnNext")=True Or SmartTags("btnPrev")=True

If SmartTags("btnNext")=True Then
rst.MoveNext
SmartTags("btnNext")=False


If SmartTags("btnPrev")=True Then
rst.MovePrevious
SmartTags("btnPrev")=False


End If
End If

ActivateScreen "Screen_1",0
Loop


Loop

Set rst = Nothing
Set conn = Nothing
 
Last edited:
My best guess

I think you will have to creat an index variable to keep track of where you are in the table. Then have two scripts for next/prev. I don't think you can keep your connection open all the time.

How many fields and records are you going to have? You could just read all the data into arrays and use them for the next/prev. You could update the arrays when the screen opens with the next/prev buttons.

Im guessing you have to use an SQL table. You could do this easy using the recipe's in Flexible.
 
Hey Charles. Sorry if my questions seem basic. I am new to WinnCC. Your right about the connection. Once i leave the script it is gone. Have not really played with the recipe's yet.
 

Similar Topics

Can someone help me. When I open winncc flexible I do not have a toolbar to open or create a new project. I have not used this software yet so am...
Replies
5
Views
2,000
When I installed WinCC Flexible it was saying that my Step7 (5.3) version is old and needs to be updated up to SP2, and as a result WinCC did not...
Replies
6
Views
9,772
On the HMI-1200, the Wall clock date shows "1/4/1970". How can I correct this? Can't seem to find where this date is coming from or how to change...
Replies
7
Views
903
In wincc server client configuration with redundant server, if the primary/master server fails and the standby does not takeover. How to...
Replies
1
Views
1,422
I have an odd situation where I turn on a valve on the HMI, and the output in the PLC is on and indicates ON in the output map. But the actual...
Replies
4
Views
1,821
Back
Top Bottom