MCTampa
Board Regular
- Joined
- Apr 14, 2016
- Messages
- 97
I have a VBA script that loops through our AS400 and changesfields based on a set of criteria loaded into a form.
There are certain times when our AS400 glitches and presentsa half screen of information. At thispoint, I want to back out of the screen and restart the process.However, if I have 5 records loaded in myform, it starts from the beginning.
I would like to have it resume the recordset where it leftoff, but I do not know how to write that.
Edit: I don’t knowwhy the website is fighting with me, but I can’t get my code in one box. Sorry.
I want to simply have the code resume the current rst atafter the “COM”, “PF2” command at the end.
Thanks
Here is my code:
There are certain times when our AS400 glitches and presentsa half screen of information. At thispoint, I want to back out of the screen and restart the process.However, if I have 5 records loaded in myform, it starts from the beginning.
I would like to have it resume the recordset where it leftoff, but I do not know how to write that.
Edit: I don’t knowwhy the website is fighting with me, but I can’t get my code in one box. Sorry.
I want to simply have the code resume the current rst atafter the “COM”, “PF2” command at the end.
Thanks
Here is my code:
Code:
Function StopSale()
Dim MySession As New AutSess
Dim SessionName As String
Dim FirstEntry, LastEntry As Integer
SessionName = "A"
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]MySession.SetConnectionByName (SessionName)
Set OIA = MySession.autECLOIA
Set PS = MySession.autECLPS[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]OIA.WaitForAppAvailable
OIA.WaitForInputReady[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim cmd1 As ADODB.Command
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim rst2 As ADODB.Recordset
Set rst2 = New ADODB.Recordset[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]With rst[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]rst.Open "select Entry,Resort_Code,AS400SD,End_Date,Unit_Size,Flag,Return,Track_Code,Res_Line,Unit_Num from Log ", CurrentProject.Connection, adOpenStatic, adLockOptimistic
Do Until rst.EOF = True[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Call sendToNa("PUT", "400", 21, 18, 0, 0) 'Go to Option 400
Call sendToNa("COM", "enter", 0, 0, 0, 0)
Call sendToNa("PUT", .Fields("Resort_Code"), 6, 43, 0, 0) 'Pass Resort ID
Call sendToNa("PUT", .Fields("AS400SD"), 8, 43, 0, 0) 'Pass Start Date
If .Fields("Track_Code") = "ALL" Then Call sendToNa("PUT", "*", 10, 43, 0, 0): Call sendToNa("COM", "enter", 0, 0, 0, 0) _
Else: Call sendToNa("COM", "PF4", 0, 0, 0, 0) 'Prompt for Track Code selection
If .Fields("Track_Code") = "C" Then Call sendToNa("PUT", "X", 16, 37, 0, 0) _
Else: If .Fields("Track_Code") = "T" Then Call sendToNa("COM", "Roll Up", 0, 0, 0, 0): Call sendToNa("COM", "Roll Up", 0, 0, 0, 0): Call sendToNa("PUT", "X", 18, 37, 0, 0)
Call sendToNa("COM", "enter", 0, 0, 0, 0)
Call sendToNa("COM", "enter", 0, 0, 0, 0)[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]
If .Fields("Unit_Size") = "9" And .Fields("Return") = "U" Then
'This macro returns all unit sizes[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Do
If PS.GetText(14, 68, 1) = " " And DateValue(PS.GetText(7, 51, 2) & " - " & PS.GetText(7, 53, 3) & " - " & PS.GetText(7, 56, 2)) <= .Fields("End_Date") Then Call sendToNa("COM", "PF2", 0, 0, 0, 0): Call sendToNa("COM", "PF2", 0, 0, 0, 0): rst.Requery[/COLOR][/SIZE][/FONT]
Last edited: