Jump to content

Help with Error Line -1


 Share

Recommended Posts

Hello forums,

I was hoping that there was a coding expert that could help me out with a coding issue we are experiencing. The company i work for used to have a scripting expert at the company but he has long since left. We have a scrap material program that we use, however it constantly gives us errors and i have no knowledge of scripting or programming. Everytime we try to run the .exe we get the following error

Line -1:

Error: The requested action with this object failed.

If anyone out there could take a look at the coding that was done years ago and let me know what they see that could be causing the problem, we would greatly appreciate it!

Thanks again in advance...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=X:MX4Shop FloorMaterial Consumption Input.exe
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;--------------------------------------------------------------------------------------------------------------------
;- Program....: Material Consumption Input.au3
;--------------------------------------------------------------------------------------------------------------------
;- Created by.: Joe Weinpert, CORSA Performance
;--------------------------------------------------------------------------------------------------------------------
;- Description: Shop floor station input screen for material consumed.
;--------------------------------------------------------------------------------------------------------------------
;- Synopsis...: Use anywhere to input material used in projects, shipping, or scrapped.
;--------------------------------------------------------------------------------------------------------------------
;- Known Bugs.:
;--------------------------------------------------------------------------------------------------------------------
;- Called By..:
;--------------------------------------------------------------------------------------------------------------------
;- Parameters.:
;--------------------------------------------------------------------------------------------------------------------
;- Requires...: AutoIt3 version: 3.2.2.0
;--------------------------------------------------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <Debug.au3>

;_DebugSetup( @ScriptName )
_Singleton( @ScriptName  ) ;- Allow only a single instance to run

Opt( "MustDeclareVars",1 )
Opt( "colorMode",     0 ) ;- RGB
Opt( "GUICloseOnESC",  0 ) ;- Don't let ESC close the window

;- Initialize general variables
Global $h, $i, $j, $k, $w, $x, $y, $z
Global $TESTING = False
Global $DEEPTESTING = False

Global $gvEvent ;- Event message in main loop
Global $gcRealStation = ""

#region ;- ADO stuff

;====================================================================================================================
;- ADO constants
;--------------------------------------------------------------------------------------------------------------------

Global Const $adUseServer = 2 ;- Server-side connection
Global Const $adUseClient = 3 ;- Client-side (local) connection

Global Const $adModeReadWrite    =  3 ;- Open connection as R/W
Global Const $adModeShareDenyNone = 16 ;- Can open other connections as R/W

Global Const $adOpenForwadOnly = 0 ;- Default CursorTypeEnum objRecordset.RecordCount = -1 (why?)
Global Const $adOpenDynamic = 2 ;- Additions, deletions, insertions, and updates
Global Const $adOpenStatic   = 3 ;- Fixed and unchangeable

Global Const $adLockBatchOptimistic =  4 ;- Multiple users can modify the data and the changes are cached until BatchUpdate is called
Global Const $adLockOptimistic    =  3 ;- Multiple users can modify the data which is not locked until Update is called
Global Const $adLockPessimistic  =  2 ;- The provider locks each record before and after you edit, and prevents other users from modifying the data
Global Const $adLockReadOnly        =  1 ;- Read-only data (default)
Global Const $adLockUnspecified  = -1 ;- Lock type unknown

Global Const $adBookmarkCurrent = 0 ;- Start search at current record (default)
Global Const $adBookmarkFirst   = 1 ;- Start search at first record
Global Const $adBookmarkLast    = 2 ;- Start search at last record

Global Const $adSearchBackward = -1 ;- Searches from starting point backward to the first record
Global Const $adSearchForward  =  1 ;- Searches from starting point forward to the last record

Global Const $adClipString = 2 ;-  Will force using ColumnDelimiter, RowDelimiter, and NullExpr parameters (default)

Global Const $adStateClosed  = 0 ;- Object is closed
Global Const $adStateConnecting = 2 ;- Object is connecting
Global Const $adStateExecuting  = 4 ;- Object is executing
Global Const $adStateFetching   = 8 ;- Object is fetching
Global Const $adStateOpen      = 1 ;- Object is open

Global Const $adEditAdd     = 2 ;- The current record is new and has been added using the AddNew method but is not saved in the database
Global Const $adEditDelete   = 4 ;- The current record has been deleted
Global Const $adEditInProgress = 1 ;- The current record has been changed but not saved in the database
Global Const $adEditNone       = 0 ;- The current record is not being edited

Global Const $adAffectAll        = 3 ;- Update all records including those hidden by a filter
Global Const $adAffectAllChapters = 4 ;- Cancels all pending updates in all child (chapter) recordsets
Global Const $adAffectCurrent    = 1 ;- Update only the current record
Global Const $adAffectGroup    = 2 ;- Update only those records that passed through the filter in effect

;====================================================================================================================
;- Create global connections to database and tables
;--------------------------------------------------------------------------------------------------------------------

;- Accpac database container T:ERPProdata.dbc
Global $prodata = ObjCreate( "ADODB.Connection" )
$prodata.Mode = $adModeShareDenyNone   ;- Can open other connections as R/W
$prodata.CursorLocation = $adUseClient ;- Client-side (local) connection
;;;;;; $prodata.Open( "Provider=vfpoledb.1;Data Source=T:ERP_SFProdata.dbc" )
$prodata.Open( "Provider=vfpoledb.1;Data Source=T:ERPProdata.dbc" )
If @Error Then
   MsgBox( 0, "ERROR", "Failed to connect with Prodata database container" )
   Exit
EndIf

;- syuuser table (user data table)
Global $syuuser = ObjCreate( "ADODB.Recordset" )
$syuuser.CursorType = $adOpenStatic ;- Fixed and unchangeable
$syuuser.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a syuuser recordset object" )
   Exit
EndIf
$syuuser.Open( "SELECT Userid, Name FROM syuuser WHERE !DELETED() AND !EMPTY( Userid ) AND Locatn = [Shop Floor] ORDER BY Userid", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "syuuser.Recordcount = " & $syuuser.RecordCount )
;MsgBox( 0,"", "syuuser.Recordcount = " & $syuuser.RecordCount )

;- icitem01 table (item table)
Global $icitem = ObjCreate( "ADODB.Recordset" )
$icitem.CursorType = $adOpenStatic  ;- Fixed and unchangeable
$icitem.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a icitem01 recordset object" )
   Exit
EndIf
$icitem.Open( "SELECT Item, Itmdesc FROM icitem01 WHERE !DELETED() ORDER BY Item", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "icitem.Recordcount = " & $icitem.RecordCount )

;- iciloc01 table (item-at-location table)
Global $iciloc = ObjCreate( "ADODB.Recordset" )
$iciloc.CursorType = $adOpenStatic  ;- Fixed and unchangeable
$iciloc.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a iciloc01 recordset object" )
   Exit
EndIf
$iciloc.Open( "SELECT Item, Loctid FROM iciloc01 WHERE !DELETED() ORDER BY Item, Loctid", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "iciloc.Recordcount = " & $iciloc.RecordCount )

;MsgBox( 0,"", "140" )
;- pesfwk01 table (shop floor workstation table)
Global $pesfwk = ObjCreate( "ADODB.Recordset" )
$pesfwk.CursorType = $adOpenStatic  ;- Fixed and unchangeable
$pesfwk.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a pesfwk01 recordset object" )
   Exit
EndIf
$pesfwk.Open( "SELECT Statno, Descrip, Netid, Users FROM pesfwk01 WHERE !DELETED() AND !EMPTY( Statno ) AND Useformc ORDER BY Statno", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfwk.Recordcount = " & $pesfwk.RecordCount )

;MsgBox( 0,"", "152" )
;- pesfgl01 table (shop floor general ledger table)
Global $pesfgl = ObjCreate( "ADODB.Recordset" )
$pesfgl.CursorType = $adOpenStatic  ;- Fixed and unchangeable
$pesfgl.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a pesfgl01 recordset object" )
   Exit
EndIf
$pesfgl.Open( "SELECT Loctid, Glcode, Glacnt FROM pesfgl01 WHERE !DELETED() ORDER BY Loctid, Glcode", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfgl.Recordcount = " & $pesfgl.RecordCount )

;MsgBox( 0,"", "164" )
;- pesfmc01 table (shop floor material consumption table)
Global $pesfmc = ObjCreate( "ADODB.Recordset" )
$pesfmc.CursorType = $adOpenStatic  ;- Fixed and unchangeable
$pesfmc.LockType   = $adLockReadOnly  ;- Read-only data (default)
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a pesfmc01 recordset object" )
   Exit
EndIf
$pesfmc.Open( "SELECT Statno, Glacnt, Reason, Descrip FROM pesfmc01 WHERE !DELETED() ORDER BY Statno, Reason", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfmc.Recordcount = " & $pesfmc.RecordCount )

;MsgBox( 0,"", "176" )
;- pesftr01 table (shop floor transaction table)
Global $pesftr = ObjCreate( "ADODB.Recordset" )
$pesftr.CursorType = $adOpenDynamic  ;- Additions, deletions, insertions, and updates
$pesftr.LockType   = $adLockOptimistic  ;- Not locked until "Update" is called
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a pesftr01 recordset object" )
   Exit
EndIf

Global $pesfrt = ObjCreate( "ADODB.Recordset" ) ;- ONLY UNTIL SCRIPT IS FIXED
$pesfrt.CursorType = $adOpenDynamic
$pesfrt.LockType   = $adLockOptimistic

;- Some temp ADO variables
Global $gcSQL
Global $dbTemp = ObjCreate( "ADODB.Recordset" )
$dbTemp.CursorType = $adOpenDynamic  ;- Additions, deletions, insertions, and updates
$dbTemp.LockType   = $adLockOptimistic  ;- Not locked until "Update" is called
If @Error Then
   MsgBox( 0, "ERROR", "Failed to create a dbTemp recordset object" )
   Exit
EndIf

;MsgBox( 0,"", "200" )
;- pesftr field names
Global $fdTimestamp
Global $fdStatno
Global $fdUserid
Global $fdNetid
Global $fdBomno
Global $fdQtymade
Global $fdScrap
Global $fdLoctid
Global $fdScraponly
Global $fdTtranno
Global $fdTdate
Global $fdNote
Global $fdApproved
Global $fdAdduser
Global $fdAdddate
Global $fdAddtime
Global $fdLckstat
Global $fdLckuser
Global $fdLckdate
Global $fdLcktime

#endregion


;- Build the form. Tab order is order controls are defined
;;;GUICtrlSetTip( -1,"Shop floor station ID. Defaults to network ID name." & @CRLF & "Change to suit using the dropdown list.","Station ID",1,1 )
;;;GUICtrlSetTip( -1,"Shop floor station name. Changes automatically with the station ID.","Station Name",1,1 )
;;;GUICtrlSetTip( -1,"Type your initials or choose from the dropdown list.","Operator Initials",1,1 )
;;;GUICtrlSetTip( -1,"Changes automatically with the operator initials.","Operator Name",1,1 )
;;;GUICtrlSetTip( -1,"Enter the magnet number of work completed on this station." & @CRLF & "A description and default quantity will appear when" & @CRLF & "a proper number has been input.","Magnet Number",1,1 )
;;;GUICtrlSetTip( -1,"Changes automatically with the magnet number.","Magnet Description",1,1 )
;;;GUICtrlSetTip( -1,"Quantity of items completed. Enter a quantity here if it is different than the default number.","Quantity",1,1 )
;;;GUICtrlSetTip( -1,"Scrap Quantity. Number of assemblies scrapped.","Scrap",1,1 )

Global $gnMainWidth   = 760 ;- Client width
Global $gnMainHeight  = 660 ;550 ;- Client height
Global $gcMainTitle   = "Shop Floor Material Consumption"
Global $gnFormBGColor = 0xFFFBF0 ;- Cream  ;- 0xFFFFE1 ;- Light Yellow
Global $gnFontSize  = 14 ;- 8.5 ;- 8.5 Tahoma seems to work best

Global $frmMain = GUICreate( $gcMainTitle, $gnMainWidth, $gnMainHeight )
GUISetBkColor( $gnFormBGColor, $frmMain )
GUISetFont( $gnFontSize, Default, Default, "Tahoma", $frmMain  )

;- Top grouping
Global $opgReporting = GUICtrlCreateGroup( " Reporting Station ", 20, 10, 720, 220 ) ;- Top group
GUICtrlCreateGroup ( "", -99, -99, 1, 1 ) ;- Close top group

;- Station list
Global $cboStation = GUICtrlCreateCombo( "", 40, 50, 100, 30, BitOR( $CBS_DROPDOWNLIST, $CBS_SORT ) )
_GUICtrlComboBox_SetMinVisible ( $cboStation, 15 ) ;- Maximum lines in dropdown list
;_DebugOut( "@ComputerName = " & @ComputerName )
;_DebugOut( "$gcRealStation = " & $gcRealStation )

Global $lblStation = GUICtrlCreateLabel( "Station", 150, 53, 62, 30 )
GUICtrlSetColor( $lblStation, 0xFF0000 ) ;- Red

Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )

;- User list
Global $cboUser = GUICtrlCreateCombo( "", 40, 140, 100, 30, BitOR( $CBS_DROPDOWN, $WS_VSCROLL, $CBS_UPPERCASE, $CBS_SORT ) )
_GUICtrlComboBox_LimitText( $cboUser, 4 ) ;- Maximum characters allowed
_GUICtrlComboBox_SetMinVisible ( $cboUser, 15 ) ;- Maximum lines in dropdown list

Global $lblUser = GUICtrlCreateLabel( "Operator", 150, 143, 78, 30 )
GUICtrlSetColor( $lblUser, 0xFF0000 ) ;- Red

Global $txtUser = GUICtrlCreateInput( "", 40, 180, 600, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )
GUICtrlSetData( $txtUser, "" )

;- Middle grouping
Global $opgItem = GUICtrlCreateGroup( " Item Information ", 20, 240, 720, 160 )
GUICtrlCreateGroup ( "",-99,-99,1,1 )

;- Item field
Global $txtItem = GUICtrlCreateInput( "", 40, 280, 560, 60, BitOR( $ES_UPPERCASE, $ES_AUTOHSCROLL ) )
GUICtrlSetFont( $txtItem, 32, 800, 0, "Tahoma" )
GUICtrlSetColor( $txtItem, 0x0000FF ) ;- Blue
GUICtrlSetLimit( $txtItem, 15 ) ;- Maximum characters allowed

Global $txtItmdesc = GUICtrlCreateInput( "", 40, 350, 680, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )

;- Loctid list
Global $cboLoctid = GUICtrlCreateCombo( "", 610, 310, 110, 30, BitOR( $CBS_DROPDOWNLIST, $CBS_SORT ) )
_GUICtrlComboBox_LimitText( $cboLoctid, 6 ) ;- Maximum characters allowed

Global $lblLoctid = GUICtrlCreateLabel( "Location", 630, 280, 80, 30 )
GUICtrlSetColor( $lblLoctid, 0xFF0000 ) ;- Red

;- Bottom grouping
Global $opgMaterial = GUICtrlCreateGroup( " Material Data ", 20, 410, 720, 170 )
GUICtrlCreateGroup ( "",-99,-99,1,1 )

;- Scrap field
Global $txtScrap = GUICtrlCreateInput( "", 40, 450, 330, 60, BitOR( $ES_UPPERCASE, $ES_AUTOHSCROLL ) )
GUICtrlSetFont( $txtScrap, 32, 800, 0, "Tahoma" )
GUICtrlSetColor( $txtScrap, 0x0000FF ) ;- Blue
GUICtrlSetLimit( $txtScrap, 12 ) ;- Maximum characters allowed

Global $lblScrap = GUICtrlCreateLabel( "Qty (record tubing and hose in feet)", 380, 470, 320, 30 )
GUICtrlSetColor( $lblScrap, 0xFF0000 ) ;- Red

Global $cboReason = GUICtrlCreateCombo( "", 40, 530, 680, 30, BitOR( $CBS_DROPDOWN, $WS_VSCROLL, $CBS_UPPERCASE, $CBS_SORT ) )

Global $lblReason = GUICtrlCreateLabel( "Reason", 650, 500, 70, 30 )
GUICtrlSetColor( $lblreason, 0xFF0000 ) ;- Red

;- Command buttons
Global $cmdOkay   = GUICtrlCreateButton( "OK",   190, 600, 100, 40, 0 ) ;- Enabled if all fields have data
Global $cmdCancel = GUICtrlCreateButton( "CANCEL", 330, 600, 100, 40, 0 ) ;- Always enabled
Global $cmdReset  = GUICtrlCreateButton( "RESET",  470, 600, 100, 40, 0 ) ;- Enabled if one field has data
GUICtrlSetState( $cmdOkay,  $GUI_DISABLE )
GUICtrlSetState( $cmdReset, $GUI_DISABLE )

;_DebugSetup( @ScriptName )
SRandom ( @SEC ) ;- Seed the random generator, which replaces "zzz" in the Timestamp field.
GUIRegisterMsg( $WM_COMMAND, "_InputTrap" )
Global $gaInputTrap = _ArrayCreate( False, False, False, False, False, False, False, False, False, False, False, False, False, False, False )
;- [0] = cboStation pick
;- [1] = cboStation exit
;- [2] = cboUser pick
;- [3] = cboUser exit
;- [4] = cboUser type
;- [5] = txtItem exit
;- [6] = txtItem type
;- [7] = cboLoctid pick
;- [8] = cboLoctid exit
;- [9] = txtScrap exit
;- [10] = txtScrap type (before showing)
;- [11] = txtScrap type (after showing)
;- [12] = cboReason pick
;- [13] = cboReason exit
;- [14] = cboReason type

_ResetFields()
_ButtonHandler()
GUISetState( @SW_SHOW ) ;- Show window/Make the window visible

While True
   $gvEvent = GUIGetMsg() ;- After every loop check if the user clicked something in the GUI window

   Select
   Case $gvEvent = $GUI_EVENT_CLOSE ;- Esc, Alt+F4, or Close
      ExitLoop

   Case $gaInputTrap[0] ;- cboStation pick. Get station description and new list of reasons
      $gaInputTrap[0] = False
     ;_DebugOut( "cboStation pick = '" & GUICtrlRead( $cboStation ) & "'" )
      If GUICtrlRead( $cboStation ) > "" Then
        
         ;- Get station description
         $pesfwk.MoveFirst
         $pesfwk.Find( "Statno = '" & GUICtrlRead( $cboStation ) & "'" )
         GUICtrlSetData( $txtStation, $pesfwk( "Descrip" ).Value )

        _ResetUserList()

         ;- Get list of reasons for this station
         GUICtrlSetData( $cboReason, "" )
        _GUICtrlComboBox_AddString( $cboReason, "" )
         ;$pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "'"
         $pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "' AND Descrip <> 'Default GL code'" ;- Build new list
         If NOT $pesfmc.EOF AND NOT $pesfmc.BOF Then
            $pesfmc.MoveFirst
            While NOT $pesfmc.EOF
              _GUICtrlComboBox_AddString( $cboReason, $pesfmc( "Descrip" ).Value )
               $pesfmc.MoveNext
            WEnd
         EndIf
         $pesfmc.Filter = ""
        _GUICtrlComboBox_SetCurSel( $cboReason, 0 ) ;- Set to first in list
      Else
         GUICtrlSetData( $txtStation, "" )
         GUICtrlSetData( $cboReason, "" )
      EndIf
     _ButtonHandler()

   Case $gaInputTrap[1] ;- cboStation exit. Nothing to do.
      $gaInputTrap[1] = False
     ;_DebugOut( "cboStation exit = '" & GUICtrlRead( $cboStation ) & "'" )

   Case $gaInputTrap[2] OR $gaInputTrap[4] ;- cboUser pick from list OR cboUser types in box. Get name
      $gaInputTrap[2] = False
      $gaInputTrap[4] = False
     ;_DebugOut( "cboUser pick or type = '" & GUICtrlRead( $cboUser ) & "'" )
      $syuuser.MoveFirst
      $syuuser.Find( "Userid = '" & GUICtrlRead( $cboUser ) & "'" )
      If NOT $syuuser.EOF Then
         GUICtrlSetData( $txtUser, $syuuser( "Name" ).Value )
      Else
         GUICtrlSetData( $txtUser, "" )
      EndIf
     _ButtonHandler()

   Case $gaInputTrap[3] ;- cboUser exit. If name never found then choose "" to empty field of unused characters
      $gaInputTrap[3] = False
      If GUICtrlRead( $txtUser ) = "" Then _GUICtrlComboBox_SelectString( $cboUser, "" )
     ;_DebugOut( "cboUser exit = '" & GUICtrlRead( $cboUser ) & "'" )

   Case $gaInputTrap[5] ;- txtItem exit. If item never found then choose "" to empty field of unused characters and then delete cboLoctid list
      $gaInputTrap[5] = False
      If GUICtrlRead( $txtItmdesc ) = "" Then
         GUICtrlSetData( $txtItem, "" )
         GUICtrlSetData( $cboLoctid, "" )
      EndIf
     _ButtonHandler()
     ;_DebugOut( "txtItem exit = '" & GUICtrlRead( $txtItem ) & "'" )

   Case $gaInputTrap[6] ;- txtItem type. Get item description and all Loctids for the item
      $gaInputTrap[6] = False
     ;_DebugOut( "txtItem type = '" & GUICtrlRead( $txtItem ) & "'" )
      $icitem.MoveFirst
      $icitem.Find( "Item = '" & GUICtrlRead( $txtItem ) & "'" )
      If NOT $icitem.EOF Then
         GUICtrlSetData( $txtItmdesc, $icitem( "Itmdesc" ).Value )
         GUICtrlSetData( $cboLoctid, "" ) ;- Empty list
         $iciloc.Filter = "Item = '" & GUICtrlRead( $txtItem ) & "'" ;- Build new list
         $iciloc.MoveFirst
         While NOT $iciloc.EOF
           _GUICtrlComboBox_AddString( $cboLoctid, $iciloc( "Loctid" ).Value )
            $iciloc.MoveNext
         WEnd
         $iciloc.Filter = ""
         If _GUICtrlComboBox_GetCount( $cboLoctid ) > 0 Then _GUICtrlComboBox_SetCurSel( $cboLoctid, 0 ) ;- Set to first in list
      Else
         GUICtrlSetData( $txtItmdesc, "" )
         GUICtrlSetData( $cboLoctid, "" )
      EndIf
     _ButtonHandler()

   Case $gaInputTrap[7] ;- cboLoctid pick. Nothing to do
      $gaInputTrap[7] = False
     ;_DebugOut( "cboLoctid pick = '" & GUICtrlRead( $cboLoctid ) & "'" )

   Case $gaInputTrap[8] ;- cboLoctid exit. Nothing to do
      $gaInputTrap[8] = False
     ;_DebugOut( "cboLoctid exit = '" & GUICtrlRead( $cboLoctid ) & "'" )

   Case $gaInputTrap[9] ;- txtScrap exit. Nothing to do
      $gaInputTrap[9] = False

   Case $gaInputTrap[10] ;- txtScrap type. Filter characters as they are typed (before being displayed)
      $gaInputTrap[10] = False
      If GUICtrlRead( $txtScrap ) > "" Then
         $x = StringRegExp( GUICtrlRead( $txtScrap ), "A-?[0-9]{0,7}.?[0-9]{0,3}", 1 )
        ;_DebugOut( "   x[0] = '" & $x[0] & "'" )
         If $x[0] <> GUICtrlRead( $txtScrap ) Then GUICtrlSetData( $txtScrap, $x[0] )
      EndIf
     ;_DebugOut( "txtScrap type = '" & GUICtrlRead( $txtScrap ) & "'" )
     _ButtonHandler()

   Case $gaInputTrap[11] ;- txtScrap exit. Nothing to do. Done below
      $gaInputTrap[11] = False

   Case $gaInputTrap[12] OR $gaInputTrap[14] ;- cboReason pick from list OR cboReason types in box. Nothing to do
      $gaInputTrap[12] = False
      $gaInputTrap[14] = False
     _ButtonHandler()
     ;_DebugOut( "cboReason pick or type = '" & GUICtrlRead( $cboReason ) & "'" )

   Case $gaInputTrap[13] ;- cboReason exit control. Nothing to do
      $gaInputTrap[13] = False
     ;_DebugOut( "cboReason exit = '" & GUICtrlRead( $cboReason ) & "'" )

   Case $gvEvent = $cmdOkay
      $fdTimestamp = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & StringFormat ( "%03d", Random( 0, 999, 1 ) )
      $fdStatno = GUICtrlRead( $cboStation )
      $fdUserid = StringStripWS( GUICtrlRead( $cboUser ), 3 )
      $fdNetid   = @ComputerName
      $fdBomno   = GUICtrlRead( $txtItem )
      $fdQtymade   = 0
      $fdScrap   = GUICtrlRead( $txtScrap )
      $fdLoctid = GUICtrlRead( $cboLoctid )
      $fdScraponly = 1 ;- .T.
      $fdTtranno   = ""
      $fdTdate   = 0 ;- Empty Date
      $fdNote     = GUICtrlRead( $cboReason )
      $fdApproved  = 0 ;- .F.
      $fdAdduser   = $fdUserid
      $fdAdddate   = @MON & "/" & @MDAY & "/" & @YEAR
      $fdAddtime   = @HOUR & ":" & @MIN & ":" & @SEC
      $fdLckstat   = ""
      $fdLckuser   = $fdUserid
      $fdLckdate   = $fdAdddate
      $fdLcktime   = $fdAddtime
#cs
     _DebugOut( _
      "$fdTimestamp = " & $fdTimestamp & @CR & _
      "$fdStatno    = " & $fdStatno & @CR & _
      "$fdUserid    = " & $fdUserid & @CR & _
      "$fdNetid  = " & $fdNetid  & @CR & _
      "$fdBomno  = " & $fdBomno  & @CR & _
      "$fdQtymade   = " & $fdQtymade   & @CR & _
      "$fdScrap  = " & $fdScrap  & @CR & _
      "$fdLoctid    = " & $fdLoctid & @CR & _
      "$fdScraponly = " & $fdScraponly & @CR & _
      "$fdTtranno   = " & $fdTtranno   & @CR & _
      "$fdTdate  = " & $fdTdate  & @CR & _
      "$fdNote    = " & $fdNote   & @CR & _
      "$fdApproved  = " & $fdApproved  & @CR & _
      "$fdAdduser   = " & $fdAdduser   & @CR & _
      "$fdAdddate   = " & $fdAdddate   & @CR & _
      "$fdAddtime   = " & $fdAddtime   & @CR & _
      "$fdLckstat   = " & $fdLckstat   & @CR & _
      "$fdLckuser   = " & $fdLckuser   & @CR & _
      "$fdLckdate   = " & $fdLckdate   & @CR & _
      "$fdLcktime   = " & $fdLcktime )
#ce
      $z = "" & _
      "   Station = " & $fdStatno & @CRLF & _
      "   User  = " & $fdUserid & @CRLF & _
      "   Item  = " & $fdBomno  & @CRLF & _
      "   Qty    = " & $fdScrap  & @CRLF & _
      "   Reason  = " & $fdNote & "  "

      If MsgBox( 4+32+256, "Shop Floor", $z & @CRLF & @CRLF & "   ARE THE ABOVE CHOICES CORRECT?   " ) = 6 Then ;- Yes
         $pesftr.Open( "SELECT * FROM pesftr01 WHERE RECNO() = 0", $prodata )
         $pesftr.AddNew
         $pesftr( "Timestamp" ) = $fdTimestamp
         $pesftr( "Statno"  ) = $fdStatno
         $pesftr( "Userid"  ) = $fdUserid
         $pesftr( "Netid"   ) = $fdNetid
         $pesftr( "Bomno"    ) = $fdBomno
         $pesftr( "Qtymade"   ) = $fdQtymade
         $pesftr( "Scrap"    ) = $fdScrap
         $pesftr( "Loctid"  ) = $fdLoctid
         $pesftr( "Scraponly" ) = $fdScraponly
         $pesftr( "Ttranno"   ) = $fdTtranno
         $pesftr( "Tdate"    ) = $fdTdate
         $pesftr( "Note"      ) = $fdNote
         $pesftr( "Approved"  ) = $fdApproved
         $pesftr( "Adduser"   ) = $fdAdduser
         $pesftr( "Adddate"   ) = $fdAdddate
         $pesftr( "Addtime"   ) = $fdAddtime
         $pesftr( "Lckstat"   ) = $fdLckstat
         $pesftr( "Lckuser"   ) = $fdLckuser
         $pesftr( "Lckdate"   ) = $fdLckdate
         $pesftr( "Lcktime"   ) = $fdLcktime
         $pesftr.Update
         $pesftr.Close
        _ResetFields()
     EndIf

   Case $gvEvent = $cmdCancel
      If $TESTING Then ConsoleWrite( "--> cmdCancel '" & GUICtrlRead( $gvEvent ) & "'" & @CRLF )
      Exit

   Case $gvEvent = $cmdReset
      If $TESTING Then ConsoleWrite( "--> cmdReset '" & GUICtrlRead( $gvEvent ) & "'" & @CRLF )
     _ResetFields()
   EndSelect
WEnd

;- Destroy the form and controls
Destroy()
GUIDelete( $frmMain )
Exit

;--------------------------------------------------------------------------------------------------------------------
; Functions
;--------------------------------------------------------------------------------------------------------------------

Func Destroy() ;- Close all tables
   If $syuuser.State = $adStateOpen Then $syuuser.Close
   If $icitem.State = $adStateOpen Then $icitem.Close
   If $iciloc.State = $adStateOpen Then $iciloc.Close
   If $pesfwk.State = $adStateOpen Then $pesfwk.Close
   If $pesfgl.State = $adStateOpen Then $pesfgl.Close
   If $pesfmc.State = $adStateOpen Then $pesfmc.Close
   If $pesftr.State = $adStateOpen Then $pesftr.Close
   If $dbTemp.State = $adStateOpen Then $dbTemp.Close
   If $prodata.State = $adStateOpen Then $prodata.Close
   Exit
EndFunc

Func _InputTrap( $hWnd, $gvEvent, $wParam, $lParam )
   Local $lnWinNotify  = _HiWord( $wParam ) ;- Notification message returned
   Local $lnWhichCtrl  = _LoWord( $wParam ) ;- Which control fired this message
   Local $lnCtrlHandle = $lParam            ;- Not currently used here Apr-26-2007

   Switch $lnWhichCtrl
   Case $cboStation
      Switch $lnWinNotify
      Case $CBN_SELCHANGE ;- User picks from drop box
         $gaInputTrap[0] = True
      Case $CBN_KILLFOCUS ;- User moves off control
         $gaInputTrap[1] = True
      EndSwitch
   Case $cboUser
      Switch $lnWinNotify
      Case $CBN_SELCHANGE ;- User picks from drop box
         $gaInputTrap[2] = True
      Case $CBN_KILLFOCUS ;- User moves off control
         $gaInputTrap[3] = True
      Case $CBN_EDITCHANGE ;- User types an entry
         $gaInputTrap[4] = True
      EndSwitch
   Case $txtItem
      Switch $lnWinNotify
      Case $EN_KILLFOCUS ;- User moves off control
         $gaInputTrap[5] = True
      Case $EN_CHANGE ;- User types an entry
        $gaInputTrap[6] = True
      EndSwitch
   Case $cboLoctid
      Switch $lnWinNotify
      Case $CBN_SELCHANGE ;- User picks from drop box
         $gaInputTrap[7] = True
      Case $CBN_KILLFOCUS ;- User moves off control
         $gaInputTrap[8] = True
      EndSwitch
   Case $txtScrap
      Switch $lnWinNotify
      Case $EN_KILLFOCUS ;- User moves off control
         $gaInputTrap[9] = True
      Case $EN_UPDATE ;- User types an entry (handle before showing)
         $gaInputTrap[10] = True
      Case $EN_CHANGE ;- User types an entry (handle after showing)
        $gaInputTrap[11] = True
      EndSwitch
   Case $cboReason
      Switch $lnWinNotify
      Case $CBN_SELCHANGE ;- User picks from drop box
         $gaInputTrap[12] = True
      Case $CBN_KILLFOCUS ;- User moves off control
         $gaInputTrap[13] = True
      Case $CBN_EDITCHANGE ;- User types an entry
         $gaInputTrap[14] = True
      EndSwitch
   EndSwitch

   Return $GUI_RUNDEFMSG
EndFunc

Func _HiWord( $pvParam )
   Return BitShift( $pvParam,16 )
EndFunc

Func _LoWord( $pvParam )
   Return BitAND( $pvParam,0xFFFF )
EndFunc

Func _ButtonHandler()
   ;- cmdCancel is always enabled
   ;- cmdReset is enabled when one field has data
   ;- cmdOkay is enabled when all fields have data
   If GUICtrlRead( $txtStation ) > "" AND GUICtrlRead( $txtUser ) > "" AND GUICtrlRead( $txtItem ) > "" AND GUICtrlRead( $txtScrap ) > "" AND GUICtrlRead( $cboReason ) > "" Then
      GUICtrlSetState( $cmdOkay, $GUI_ENABLE )
   Else
      GUICtrlSetState( $cmdOkay, $GUI_DISABLE )
   EndIf
   If GUICtrlRead( $txtStation ) > "" OR GUICtrlRead( $txtUser ) > "" OR GUICtrlRead( $txtItem ) > "" OR GUICtrlRead( $txtScrap ) > "" OR GUICtrlRead( $cboReason ) > "" Then
      GUICtrlSetState( $cmdReset, $GUI_ENABLE )
   Else
      GUICtrlSetState( $cmdReset, $GUI_DISABLE )
   EndIf
EndFunc

Func _ResetFields()
   ;- Station
   GUICtrlSetData( $cboStation, "" )
  _GUICtrlComboBox_AddString( $cboStation, "" )
   $pesfwk.MoveFirst
   While NOT $pesfwk.EOF
     _GUICtrlComboBox_AddString( $cboStation, $pesfwk( "Statno" ).Value )
      $pesfwk.MoveNext
   WEnd
   $pesfwk.MoveFirst
   $pesfwk.Find( "Netid = '" & @ComputerName & "'" )
   If NOT $pesfwk.EOF Then $gcRealStation = $pesfwk( "Statno" ).Value
  _GUICtrlComboBox_SelectString( $cboStation, $gcRealStation )

   $pesfwk.Find( "Statno = '" & GUICtrlRead( $cboStation ) & "'" )
   If NOT $pesfwk.EOF Then
      GUICtrlSetData( $txtStation, $pesfwk( "Descrip" ).Value )
   Else
      GUICtrlSetData( $txtStation, "" )
   EndIf

   ;- User
  _ResetUserList()
;   GUICtrlSetData( $cboUser, "" )
;  _GUICtrlComboBox_AddString( $cboUser, "" )
;   $syuuser.MoveFirst
;   While NOT $syuuser.EOF
;    _GUICtrlComboBox_AddString( $cboUser, $syuuser( "Userid" ).Value )
;     $syuuser.MoveNext
;   WEnd
;  _GUICtrlComboBox_SelectString( $cboUser, "" )
;   GUICtrlSetData( $txtUser, "" )

   ;- Item
   GUICtrlSetData( $txtItem, "" )
   GUICtrlSetData( $txtItmdesc, "" )
   GUICtrlSetData( $cboLoctid, "" )

   ;- Material
   GUICtrlSetData( $txtScrap, "" )
   GUICtrlSetData( $cboReason, "" )
   If GUICtrlRead( $cboStation ) > "" Then
     _GUICtrlComboBox_AddString( $cboReason, "" )
      $pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "' AND Descrip <> 'Default GL code'" ;- Build new list
      If NOT $pesfmc.EOF AND NOT $pesfmc.BOF Then
         $pesfmc.MoveFirst
         While NOT $pesfmc.EOF
           _GUICtrlComboBox_AddString( $cboReason, $pesfmc( "Descrip" ).Value )
            $pesfmc.MoveNext
         WEnd
        _GUICtrlComboBox_SetCurSel( $cboReason, 0 ) ;- Set to first in list
      EndIf
      $pesfmc.Filter = ""
   EndIf
EndFunc

Func _ResetUserList()
   GUICtrlSetData( $cboUser, "" )
  _GUICtrlComboBox_AddString( $cboUser, "" )
   If GUICtrlRead( $cboStation ) > "" Then
      $pesfwk.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "'" ;- Build user list for this station
      If NOT $pesfwk.EOF AND NOT $pesfwk.BOF Then
         $pesfwk.MoveFirst
         $x = StringSplit( $pesfwk( "Users" ).Value, "," )
         If $x[1] > "" Then
            For $i = 1 To $x[0]
             _GUICtrlComboBox_AddString( $cboUser, $x[$i] )
            Next
         EndIf
      EndIf
      $pesfwk.Filter = ""
   EndIf
  _GUICtrlComboBox_SelectString( $cboUser, "" )
   GUICtrlSetData( $txtUser, "" )
EndFunc





;--------------------------------------------------------------------------------------------------------------------
; Unused and/or programming code
;--------------------------------------------------------------------------------------------------------------------
#region
#cs
#ce
#endregion
Edited by Jos
added CODE box
Link to comment
Share on other sites

Buddy, that is a massive script to be Posting like that.

press quote on this post to see how you can edit it, to look like below.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=X:MX4Shop FloorMaterial Consumption Input.exe
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;--------------------------------------------------------------------------------------------------------------------
;- Program....: Material Consumption Input.au3
;--------------------------------------------------------------------------------------------------------------------
;- Created by.: Joe Weinpert, CORSA Performance
;--------------------------------------------------------------------------------------------------------------------
;- Description: Shop floor station input screen for material consumed.
;--------------------------------------------------------------------------------------------------------------------
;- Synopsis...: Use anywhere to input material used in projects, shipping, or scrapped.
;--------------------------------------------------------------------------------------------------------------------
;- Known Bugs.:
;--------------------------------------------------------------------------------------------------------------------
;- Called By..:
;--------------------------------------------------------------------------------------------------------------------
;- Parameters.:
;--------------------------------------------------------------------------------------------------------------------
;- Requires...: AutoIt3 version: 3.2.2.0
;--------------------------------------------------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <Debug.au3>
;_DebugSetup( @ScriptName )
_Singleton( @ScriptName ) ;- Allow only a single instance to run
Opt( "MustDeclareVars",1 )
Opt( "colorMode",  0 ) ;- RGB
Opt( "GUICloseOnESC", 0 ) ;- Don't let ESC close the window
;- Initialize general variables
Global $h, $i, $j, $k, $w, $x, $y, $z
Global $TESTING = False
Global $DEEPTESTING = False
Global $gvEvent ;- Event message in main loop
Global $gcRealStation = ""
#region ;- ADO stuff
;====================================================================================================================
;- ADO constants
;--------------------------------------------------------------------------------------------------------------------
Global Const $adUseServer = 2 ;- Server-side connection
Global Const $adUseClient = 3 ;- Client-side (local) connection
Global Const $adModeReadWrite  = 3 ;- Open connection as R/W
Global Const $adModeShareDenyNone = 16 ;- Can open other connections as R/W
Global Const $adOpenForwadOnly = 0 ;- Default CursorTypeEnum objRecordset.RecordCount = -1 (why?)
Global Const $adOpenDynamic = 2 ;- Additions, deletions, insertions, and updates
Global Const $adOpenStatic  = 3 ;- Fixed and unchangeable
Global Const $adLockBatchOptimistic = 4 ;- Multiple users can modify the data and the changes are cached until BatchUpdate is called
Global Const $adLockOptimistic  = 3 ;- Multiple users can modify the data which is not locked until Update is called
Global Const $adLockPessimistic  = 2 ;- The provider locks each record before and after you edit, and prevents other users from modifying the data
Global Const $adLockReadOnly  = 1 ;- Read-only data (default)
Global Const $adLockUnspecified  = -1 ;- Lock type unknown
Global Const $adBookmarkCurrent = 0 ;- Start search at current record (default)
Global Const $adBookmarkFirst = 1 ;- Start search at first record
Global Const $adBookmarkLast = 2 ;- Start search at last record
Global Const $adSearchBackward = -1 ;- Searches from starting point backward to the first record
Global Const $adSearchForward = 1 ;- Searches from starting point forward to the last record
Global Const $adClipString = 2 ;- Will force using ColumnDelimiter, RowDelimiter, and NullExpr parameters (default)
Global Const $adStateClosed  = 0 ;- Object is closed
Global Const $adStateConnecting = 2 ;- Object is connecting
Global Const $adStateExecuting = 4 ;- Object is executing
Global Const $adStateFetching = 8 ;- Object is fetching
Global Const $adStateOpen  = 1 ;- Object is open
Global Const $adEditAdd  = 2 ;- The current record is new and has been added using the AddNew method but is not saved in the database
Global Const $adEditDelete  = 4 ;- The current record has been deleted
Global Const $adEditInProgress = 1 ;- The current record has been changed but not saved in the database
Global Const $adEditNone  = 0 ;- The current record is not being edited
Global Const $adAffectAll  = 3 ;- Update all records including those hidden by a filter
Global Const $adAffectAllChapters = 4 ;- Cancels all pending updates in all child (chapter) recordsets
Global Const $adAffectCurrent  = 1 ;- Update only the current record
Global Const $adAffectGroup  = 2 ;- Update only those records that passed through the filter in effect
;====================================================================================================================
;- Create global connections to database and tables
;--------------------------------------------------------------------------------------------------------------------
;- Accpac database container T:ERPProdata.dbc
Global $prodata = ObjCreate( "ADODB.Connection" )
$prodata.Mode = $adModeShareDenyNone ;- Can open other connections as R/W
$prodata.CursorLocation = $adUseClient ;- Client-side (local) connection
;;;;;; $prodata.Open( "Provider=vfpoledb.1;Data Source=T:ERP_SFProdata.dbc" )
$prodata.Open( "Provider=vfpoledb.1;Data Source=T:ERPProdata.dbc" )
If @Error Then
MsgBox( 0, "ERROR", "Failed to connect with Prodata database container" )
Exit
EndIf
;- syuuser table (user data table)
Global $syuuser = ObjCreate( "ADODB.Recordset" )
$syuuser.CursorType = $adOpenStatic ;- Fixed and unchangeable
$syuuser.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a syuuser recordset object" )
Exit
EndIf
$syuuser.Open( "SELECT Userid, Name FROM syuuser WHERE !DELETED() AND !EMPTY( Userid ) AND Locatn = [Shop Floor] ORDER BY Userid", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "syuuser.Recordcount = " & $syuuser.RecordCount )
;MsgBox( 0,"", "syuuser.Recordcount = " & $syuuser.RecordCount )
;- icitem01 table (item table)
Global $icitem = ObjCreate( "ADODB.Recordset" )
$icitem.CursorType = $adOpenStatic ;- Fixed and unchangeable
$icitem.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a icitem01 recordset object" )
Exit
EndIf
$icitem.Open( "SELECT Item, Itmdesc FROM icitem01 WHERE !DELETED() ORDER BY Item", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "icitem.Recordcount = " & $icitem.RecordCount )
;- iciloc01 table (item-at-location table)
Global $iciloc = ObjCreate( "ADODB.Recordset" )
$iciloc.CursorType = $adOpenStatic ;- Fixed and unchangeable
$iciloc.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a iciloc01 recordset object" )
Exit
EndIf
$iciloc.Open( "SELECT Item, Loctid FROM iciloc01 WHERE !DELETED() ORDER BY Item, Loctid", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "iciloc.Recordcount = " & $iciloc.RecordCount )
;MsgBox( 0,"", "140" )
;- pesfwk01 table (shop floor workstation table)
Global $pesfwk = ObjCreate( "ADODB.Recordset" )
$pesfwk.CursorType = $adOpenStatic ;- Fixed and unchangeable
$pesfwk.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a pesfwk01 recordset object" )
Exit
EndIf
$pesfwk.Open( "SELECT Statno, Descrip, Netid, Users FROM pesfwk01 WHERE !DELETED() AND !EMPTY( Statno ) AND Useformc ORDER BY Statno", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfwk.Recordcount = " & $pesfwk.RecordCount )
;MsgBox( 0,"", "152" )
;- pesfgl01 table (shop floor general ledger table)
Global $pesfgl = ObjCreate( "ADODB.Recordset" )
$pesfgl.CursorType = $adOpenStatic ;- Fixed and unchangeable
$pesfgl.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a pesfgl01 recordset object" )
Exit
EndIf
$pesfgl.Open( "SELECT Loctid, Glcode, Glacnt FROM pesfgl01 WHERE !DELETED() ORDER BY Loctid, Glcode", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfgl.Recordcount = " & $pesfgl.RecordCount )
;MsgBox( 0,"", "164" )
;- pesfmc01 table (shop floor material consumption table)
Global $pesfmc = ObjCreate( "ADODB.Recordset" )
$pesfmc.CursorType = $adOpenStatic ;- Fixed and unchangeable
$pesfmc.LockType = $adLockReadOnly ;- Read-only data (default)
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a pesfmc01 recordset object" )
Exit
EndIf
$pesfmc.Open( "SELECT Statno, Glacnt, Reason, Descrip FROM pesfmc01 WHERE !DELETED() ORDER BY Statno, Reason", $prodata, $adOpenStatic, $adLockReadOnly )
;_DebugOut( "pesfmc.Recordcount = " & $pesfmc.RecordCount )
;MsgBox( 0,"", "176" )
;- pesftr01 table (shop floor transaction table)
Global $pesftr = ObjCreate( "ADODB.Recordset" )
$pesftr.CursorType = $adOpenDynamic  ;- Additions, deletions, insertions, and updates
$pesftr.LockType = $adLockOptimistic ;- Not locked until "Update" is called
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a pesftr01 recordset object" )
Exit
EndIf
Global $pesfrt = ObjCreate( "ADODB.Recordset" ) ;- ONLY UNTIL SCRIPT IS FIXED
$pesfrt.CursorType = $adOpenDynamic
$pesfrt.LockType = $adLockOptimistic
;- Some temp ADO variables
Global $gcSQL
Global $dbTemp = ObjCreate( "ADODB.Recordset" )
$dbTemp.CursorType = $adOpenDynamic  ;- Additions, deletions, insertions, and updates
$dbTemp.LockType = $adLockOptimistic ;- Not locked until "Update" is called
If @Error Then
MsgBox( 0, "ERROR", "Failed to create a dbTemp recordset object" )
Exit
EndIf
;MsgBox( 0,"", "200" )
;- pesftr field names
Global $fdTimestamp
Global $fdStatno
Global $fdUserid
Global $fdNetid
Global $fdBomno
Global $fdQtymade
Global $fdScrap
Global $fdLoctid
Global $fdScraponly
Global $fdTtranno
Global $fdTdate
Global $fdNote
Global $fdApproved
Global $fdAdduser
Global $fdAdddate
Global $fdAddtime
Global $fdLckstat
Global $fdLckuser
Global $fdLckdate
Global $fdLcktime
#endregion

;- Build the form. Tab order is order controls are defined
;;;GUICtrlSetTip( -1,"Shop floor station ID. Defaults to network ID name." & @CRLF & "Change to suit using the dropdown list.","Station ID",1,1 )
;;;GUICtrlSetTip( -1,"Shop floor station name. Changes automatically with the station ID.","Station Name",1,1 )
;;;GUICtrlSetTip( -1,"Type your initials or choose from the dropdown list.","Operator Initials",1,1 )
;;;GUICtrlSetTip( -1,"Changes automatically with the operator initials.","Operator Name",1,1 )
;;;GUICtrlSetTip( -1,"Enter the magnet number of work completed on this station." & @CRLF & "A description and default quantity will appear when" & @CRLF & "a proper number has been input.","Magnet Number",1,1 )
;;;GUICtrlSetTip( -1,"Changes automatically with the magnet number.","Magnet Description",1,1 )
;;;GUICtrlSetTip( -1,"Quantity of items completed. Enter a quantity here if it is different than the default number.","Quantity",1,1 )
;;;GUICtrlSetTip( -1,"Scrap Quantity. Number of assemblies scrapped.","Scrap",1,1 )
Global $gnMainWidth = 760 ;- Client width
Global $gnMainHeight = 660 ;550 ;- Client height
Global $gcMainTitle = "Shop Floor Material Consumption"
Global $gnFormBGColor = 0xFFFBF0 ;- Cream ;- 0xFFFFE1 ;- Light Yellow
Global $gnFontSize = 14 ;- 8.5 ;- 8.5 Tahoma seems to work best
Global $frmMain = GUICreate( $gcMainTitle, $gnMainWidth, $gnMainHeight )
GUISetBkColor( $gnFormBGColor, $frmMain )
GUISetFont( $gnFontSize, Default, Default, "Tahoma", $frmMain )
;- Top grouping
Global $opgReporting = GUICtrlCreateGroup( " Reporting Station ", 20, 10, 720, 220 ) ;- Top group
GUICtrlCreateGroup ( "", -99, -99, 1, 1 ) ;- Close top group
;- Station list
Global $cboStation = GUICtrlCreateCombo( "", 40, 50, 100, 30, BitOR( $CBS_DROPDOWNLIST, $CBS_SORT ) )
_GUICtrlComboBox_SetMinVisible ( $cboStation, 15 ) ;- Maximum lines in dropdown list
;_DebugOut( "@ComputerName = " & @ComputerName )
;_DebugOut( "$gcRealStation = " & $gcRealStation )
Global $lblStation = GUICtrlCreateLabel( "Station", 150, 53, 62, 30 )
GUICtrlSetColor( $lblStation, 0xFF0000 ) ;- Red
Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )
;- User list
Global $cboUser = GUICtrlCreateCombo( "", 40, 140, 100, 30, BitOR( $CBS_DROPDOWN, $WS_VSCROLL, $CBS_UPPERCASE, $CBS_SORT ) )
_GUICtrlComboBox_LimitText( $cboUser, 4 ) ;- Maximum characters allowed
_GUICtrlComboBox_SetMinVisible ( $cboUser, 15 ) ;- Maximum lines in dropdown list
Global $lblUser = GUICtrlCreateLabel( "Operator", 150, 143, 78, 30 )
GUICtrlSetColor( $lblUser, 0xFF0000 ) ;- Red
Global $txtUser = GUICtrlCreateInput( "", 40, 180, 600, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )
GUICtrlSetData( $txtUser, "" )
;- Middle grouping
Global $opgItem = GUICtrlCreateGroup( " Item Information ", 20, 240, 720, 160 )
GUICtrlCreateGroup ( "",-99,-99,1,1 )
;- Item field
Global $txtItem = GUICtrlCreateInput( "", 40, 280, 560, 60, BitOR( $ES_UPPERCASE, $ES_AUTOHSCROLL ) )
GUICtrlSetFont( $txtItem, 32, 800, 0, "Tahoma" )
GUICtrlSetColor( $txtItem, 0x0000FF ) ;- Blue
GUICtrlSetLimit( $txtItem, 15 ) ;- Maximum characters allowed
Global $txtItmdesc = GUICtrlCreateInput( "", 40, 350, 680, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY ) )
;- Loctid list
Global $cboLoctid = GUICtrlCreateCombo( "", 610, 310, 110, 30, BitOR( $CBS_DROPDOWNLIST, $CBS_SORT ) )
_GUICtrlComboBox_LimitText( $cboLoctid, 6 ) ;- Maximum characters allowed
Global $lblLoctid = GUICtrlCreateLabel( "Location", 630, 280, 80, 30 )
GUICtrlSetColor( $lblLoctid, 0xFF0000 ) ;- Red
;- Bottom grouping
Global $opgMaterial = GUICtrlCreateGroup( " Material Data ", 20, 410, 720, 170 )
GUICtrlCreateGroup ( "",-99,-99,1,1 )
;- Scrap field
Global $txtScrap = GUICtrlCreateInput( "", 40, 450, 330, 60, BitOR( $ES_UPPERCASE, $ES_AUTOHSCROLL ) )
GUICtrlSetFont( $txtScrap, 32, 800, 0, "Tahoma" )
GUICtrlSetColor( $txtScrap, 0x0000FF ) ;- Blue
GUICtrlSetLimit( $txtScrap, 12 ) ;- Maximum characters allowed
Global $lblScrap = GUICtrlCreateLabel( "Qty (record tubing and hose in feet)", 380, 470, 320, 30 )
GUICtrlSetColor( $lblScrap, 0xFF0000 ) ;- Red
Global $cboReason = GUICtrlCreateCombo( "", 40, 530, 680, 30, BitOR( $CBS_DROPDOWN, $WS_VSCROLL, $CBS_UPPERCASE, $CBS_SORT ) )
Global $lblReason = GUICtrlCreateLabel( "Reason", 650, 500, 70, 30 )
GUICtrlSetColor( $lblreason, 0xFF0000 ) ;- Red
;- Command buttons
Global $cmdOkay = GUICtrlCreateButton( "OK",  190, 600, 100, 40, 0 ) ;- Enabled if all fields have data
Global $cmdCancel = GUICtrlCreateButton( "CANCEL", 330, 600, 100, 40, 0 ) ;- Always enabled
Global $cmdReset = GUICtrlCreateButton( "RESET", 470, 600, 100, 40, 0 ) ;- Enabled if one field has data
GUICtrlSetState( $cmdOkay, $GUI_DISABLE )
GUICtrlSetState( $cmdReset, $GUI_DISABLE )
;_DebugSetup( @ScriptName )
SRandom ( @SEC ) ;- Seed the random generator, which replaces "zzz" in the Timestamp field.
GUIRegisterMsg( $WM_COMMAND, "_InputTrap" )
Global $gaInputTrap = _ArrayCreate( False, False, False, False, False, False, False, False, False, False, False, False, False, False, False )
;- [0] = cboStation pick
;- [1] = cboStation exit
;- [2] = cboUser pick
;- [3] = cboUser exit
;- [4] = cboUser type
;- [5] = txtItem exit
;- [6] = txtItem type
;- [7] = cboLoctid pick
;- [8] = cboLoctid exit
;- [9] = txtScrap exit
;- [10] = txtScrap type (before showing)
;- [11] = txtScrap type (after showing)
;- [12] = cboReason pick
;- [13] = cboReason exit
;- [14] = cboReason type
_ResetFields()
_ButtonHandler()
GUISetState( @SW_SHOW ) ;- Show window/Make the window visible
While True
$gvEvent = GUIGetMsg() ;- After every loop check if the user clicked something in the GUI window
Select
Case $gvEvent = $GUI_EVENT_CLOSE ;- Esc, Alt+F4, or Close
ExitLoop
Case $gaInputTrap[0] ;- cboStation pick. Get station description and new list of reasons
$gaInputTrap[0] = False
;_DebugOut( "cboStation pick = '" & GUICtrlRead( $cboStation ) & "'" )
If GUICtrlRead( $cboStation ) > "" Then
;- Get station description
$pesfwk.MoveFirst
$pesfwk.Find( "Statno = '" & GUICtrlRead( $cboStation ) & "'" )
GUICtrlSetData( $txtStation, $pesfwk( "Descrip" ).Value )
_ResetUserList()
;- Get list of reasons for this station
GUICtrlSetData( $cboReason, "" )
_GUICtrlComboBox_AddString( $cboReason, "" )
;$pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "'"
$pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "' AND Descrip <> 'Default GL code'" ;- Build new list
If NOT $pesfmc.EOF AND NOT $pesfmc.BOF Then
$pesfmc.MoveFirst
While NOT $pesfmc.EOF
_GUICtrlComboBox_AddString( $cboReason, $pesfmc( "Descrip" ).Value )
$pesfmc.MoveNext
WEnd
EndIf
$pesfmc.Filter = ""
_GUICtrlComboBox_SetCurSel( $cboReason, 0 ) ;- Set to first in list
Else
GUICtrlSetData( $txtStation, "" )
GUICtrlSetData( $cboReason, "" )
EndIf
_ButtonHandler()
Case $gaInputTrap[1] ;- cboStation exit. Nothing to do.
$gaInputTrap[1] = False
;_DebugOut( "cboStation exit = '" & GUICtrlRead( $cboStation ) & "'" )
Case $gaInputTrap[2] OR $gaInputTrap[4] ;- cboUser pick from list OR cboUser types in box. Get name
$gaInputTrap[2] = False
$gaInputTrap[4] = False
;_DebugOut( "cboUser pick or type = '" & GUICtrlRead( $cboUser ) & "'" )
$syuuser.MoveFirst
$syuuser.Find( "Userid = '" & GUICtrlRead( $cboUser ) & "'" )
If NOT $syuuser.EOF Then
GUICtrlSetData( $txtUser, $syuuser( "Name" ).Value )
Else
GUICtrlSetData( $txtUser, "" )
EndIf
_ButtonHandler()
Case $gaInputTrap[3] ;- cboUser exit. If name never found then choose "" to empty field of unused characters
$gaInputTrap[3] = False
If GUICtrlRead( $txtUser ) = "" Then _GUICtrlComboBox_SelectString( $cboUser, "" )
;_DebugOut( "cboUser exit = '" & GUICtrlRead( $cboUser ) & "'" )
Case $gaInputTrap[5] ;- txtItem exit. If item never found then choose "" to empty field of unused characters and then delete cboLoctid list
$gaInputTrap[5] = False
If GUICtrlRead( $txtItmdesc ) = "" Then
GUICtrlSetData( $txtItem, "" )
GUICtrlSetData( $cboLoctid, "" )
EndIf
_ButtonHandler()
;_DebugOut( "txtItem exit = '" & GUICtrlRead( $txtItem ) & "'" )
Case $gaInputTrap[6] ;- txtItem type. Get item description and all Loctids for the item
$gaInputTrap[6] = False
;_DebugOut( "txtItem type = '" & GUICtrlRead( $txtItem ) & "'" )
$icitem.MoveFirst
$icitem.Find( "Item = '" & GUICtrlRead( $txtItem ) & "'" )
If NOT $icitem.EOF Then
GUICtrlSetData( $txtItmdesc, $icitem( "Itmdesc" ).Value )
GUICtrlSetData( $cboLoctid, "" ) ;- Empty list
$iciloc.Filter = "Item = '" & GUICtrlRead( $txtItem ) & "'" ;- Build new list
$iciloc.MoveFirst
While NOT $iciloc.EOF
_GUICtrlComboBox_AddString( $cboLoctid, $iciloc( "Loctid" ).Value )
$iciloc.MoveNext
WEnd
$iciloc.Filter = ""
If _GUICtrlComboBox_GetCount( $cboLoctid ) > 0 Then _GUICtrlComboBox_SetCurSel( $cboLoctid, 0 ) ;- Set to first in list
Else
GUICtrlSetData( $txtItmdesc, "" )
GUICtrlSetData( $cboLoctid, "" )
EndIf
_ButtonHandler()
Case $gaInputTrap[7] ;- cboLoctid pick. Nothing to do
$gaInputTrap[7] = False
;_DebugOut( "cboLoctid pick = '" & GUICtrlRead( $cboLoctid ) & "'" )
Case $gaInputTrap[8] ;- cboLoctid exit. Nothing to do
$gaInputTrap[8] = False
;_DebugOut( "cboLoctid exit = '" & GUICtrlRead( $cboLoctid ) & "'" )
Case $gaInputTrap[9] ;- txtScrap exit. Nothing to do
$gaInputTrap[9] = False
Case $gaInputTrap[10] ;- txtScrap type. Filter characters as they are typed (before being displayed)
$gaInputTrap[10] = False
If GUICtrlRead( $txtScrap ) > "" Then
$x = StringRegExp( GUICtrlRead( $txtScrap ), "A-?[0-9]{0,7}.?[0-9]{0,3}", 1 )
;_DebugOut( " x[0] = '" & $x[0] & "'" )
If $x[0] <> GUICtrlRead( $txtScrap ) Then GUICtrlSetData( $txtScrap, $x[0] )
EndIf
;_DebugOut( "txtScrap type = '" & GUICtrlRead( $txtScrap ) & "'" )
_ButtonHandler()
Case $gaInputTrap[11] ;- txtScrap exit. Nothing to do. Done below
$gaInputTrap[11] = False
Case $gaInputTrap[12] OR $gaInputTrap[14] ;- cboReason pick from list OR cboReason types in box. Nothing to do
$gaInputTrap[12] = False
$gaInputTrap[14] = False
_ButtonHandler()
;_DebugOut( "cboReason pick or type = '" & GUICtrlRead( $cboReason ) & "'" )
Case $gaInputTrap[13] ;- cboReason exit control. Nothing to do
$gaInputTrap[13] = False
;_DebugOut( "cboReason exit = '" & GUICtrlRead( $cboReason ) & "'" )
Case $gvEvent = $cmdOkay
$fdTimestamp = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & StringFormat ( "%03d", Random( 0, 999, 1 ) )
$fdStatno = GUICtrlRead( $cboStation )
$fdUserid = StringStripWS( GUICtrlRead( $cboUser ), 3 )
$fdNetid  = @ComputerName
$fdBomno  = GUICtrlRead( $txtItem )
$fdQtymade = 0
$fdScrap  = GUICtrlRead( $txtScrap )
$fdLoctid = GUICtrlRead( $cboLoctid )
$fdScraponly = 1 ;- .T.
$fdTtranno = ""
$fdTdate  = 0 ;- Empty Date
$fdNote  = GUICtrlRead( $cboReason )
$fdApproved = 0 ;- .F.
$fdAdduser = $fdUserid
$fdAdddate = @MON & "/" & @MDAY & "/" & @YEAR
$fdAddtime = @HOUR & ":" & @MIN & ":" & @SEC
$fdLckstat = ""
$fdLckuser = $fdUserid
$fdLckdate = $fdAdddate
$fdLcktime = $fdAddtime
#cs
_DebugOut( _
"$fdTimestamp = " & $fdTimestamp & @CR & _
"$fdStatno = " & $fdStatno & @CR & _
"$fdUserid = " & $fdUserid & @CR & _
"$fdNetid  = " & $fdNetid  & @CR & _
"$fdBomno  = " & $fdBomno  & @CR & _
"$fdQtymade = " & $fdQtymade & @CR & _
"$fdScrap  = " & $fdScrap  & @CR & _
"$fdLoctid = " & $fdLoctid & @CR & _
"$fdScraponly = " & $fdScraponly & @CR & _
"$fdTtranno = " & $fdTtranno & @CR & _
"$fdTdate  = " & $fdTdate  & @CR & _
"$fdNote  = " & $fdNote  & @CR & _
"$fdApproved = " & $fdApproved & @CR & _
"$fdAdduser = " & $fdAdduser & @CR & _
"$fdAdddate = " & $fdAdddate & @CR & _
"$fdAddtime = " & $fdAddtime & @CR & _
"$fdLckstat = " & $fdLckstat & @CR & _
"$fdLckuser = " & $fdLckuser & @CR & _
"$fdLckdate = " & $fdLckdate & @CR & _
"$fdLcktime = " & $fdLcktime )
#ce
$z = "" & _
" Station = " & $fdStatno & @CRLF & _
" User = " & $fdUserid & @CRLF & _
" Item = " & $fdBomno & @CRLF & _
" Qty  = " & $fdScrap & @CRLF & _
" Reason = " & $fdNote & "  "
If MsgBox( 4+32+256, "Shop Floor", $z & @CRLF & @CRLF & " ARE THE ABOVE CHOICES CORRECT? " ) = 6 Then ;- Yes
$pesftr.Open( "SELECT * FROM pesftr01 WHERE RECNO() = 0", $prodata )
$pesftr.AddNew
$pesftr( "Timestamp" ) = $fdTimestamp
$pesftr( "Statno" ) = $fdStatno
$pesftr( "Userid" ) = $fdUserid
$pesftr( "Netid" ) = $fdNetid
$pesftr( "Bomno"  ) = $fdBomno
$pesftr( "Qtymade" ) = $fdQtymade
$pesftr( "Scrap"  ) = $fdScrap
$pesftr( "Loctid" ) = $fdLoctid
$pesftr( "Scraponly" ) = $fdScraponly
$pesftr( "Ttranno" ) = $fdTtranno
$pesftr( "Tdate"  ) = $fdTdate
$pesftr( "Note"  ) = $fdNote
$pesftr( "Approved" ) = $fdApproved
$pesftr( "Adduser" ) = $fdAdduser
$pesftr( "Adddate" ) = $fdAdddate
$pesftr( "Addtime" ) = $fdAddtime
$pesftr( "Lckstat" ) = $fdLckstat
$pesftr( "Lckuser" ) = $fdLckuser
$pesftr( "Lckdate" ) = $fdLckdate
$pesftr( "Lcktime" ) = $fdLcktime
$pesftr.Update
$pesftr.Close
_ResetFields()
EndIf
Case $gvEvent = $cmdCancel
If $TESTING Then ConsoleWrite( "--> cmdCancel '" & GUICtrlRead( $gvEvent ) & "'" & @CRLF )
Exit
Case $gvEvent = $cmdReset
If $TESTING Then ConsoleWrite( "--> cmdReset '" & GUICtrlRead( $gvEvent ) & "'" & @CRLF )
_ResetFields()
EndSelect
WEnd
;- Destroy the form and controls
Destroy()
GUIDelete( $frmMain )
Exit
;--------------------------------------------------------------------------------------------------------------------
; Functions
;--------------------------------------------------------------------------------------------------------------------
Func Destroy() ;- Close all tables
If $syuuser.State = $adStateOpen Then $syuuser.Close
If $icitem.State = $adStateOpen Then $icitem.Close
If $iciloc.State = $adStateOpen Then $iciloc.Close
If $pesfwk.State = $adStateOpen Then $pesfwk.Close
If $pesfgl.State = $adStateOpen Then $pesfgl.Close
If $pesfmc.State = $adStateOpen Then $pesfmc.Close
If $pesftr.State = $adStateOpen Then $pesftr.Close
If $dbTemp.State = $adStateOpen Then $dbTemp.Close
If $prodata.State = $adStateOpen Then $prodata.Close
Exit
EndFunc
Func _InputTrap( $hWnd, $gvEvent, $wParam, $lParam )
Local $lnWinNotify = _HiWord( $wParam ) ;- Notification message returned
Local $lnWhichCtrl = _LoWord( $wParam ) ;- Which control fired this message
Local $lnCtrlHandle = $lParam  ;- Not currently used here Apr-26-2007
Switch $lnWhichCtrl
Case $cboStation
Switch $lnWinNotify
Case $CBN_SELCHANGE ;- User picks from drop box
$gaInputTrap[0] = True
Case $CBN_KILLFOCUS ;- User moves off control
$gaInputTrap[1] = True
EndSwitch
Case $cboUser
Switch $lnWinNotify
Case $CBN_SELCHANGE ;- User picks from drop box
$gaInputTrap[2] = True
Case $CBN_KILLFOCUS ;- User moves off control
$gaInputTrap[3] = True
Case $CBN_EDITCHANGE ;- User types an entry
$gaInputTrap[4] = True
EndSwitch
Case $txtItem
Switch $lnWinNotify
Case $EN_KILLFOCUS ;- User moves off control
$gaInputTrap[5] = True
Case $EN_CHANGE ;- User types an entry
$gaInputTrap[6] = True
EndSwitch
Case $cboLoctid
Switch $lnWinNotify
Case $CBN_SELCHANGE ;- User picks from drop box
$gaInputTrap[7] = True
Case $CBN_KILLFOCUS ;- User moves off control
$gaInputTrap[8] = True
EndSwitch
Case $txtScrap
Switch $lnWinNotify
Case $EN_KILLFOCUS ;- User moves off control
$gaInputTrap[9] = True
Case $EN_UPDATE ;- User types an entry (handle before showing)
$gaInputTrap[10] = True
Case $EN_CHANGE ;- User types an entry (handle after showing)
$gaInputTrap[11] = True
EndSwitch
Case $cboReason
Switch $lnWinNotify
Case $CBN_SELCHANGE ;- User picks from drop box
$gaInputTrap[12] = True
Case $CBN_KILLFOCUS ;- User moves off control
$gaInputTrap[13] = True
Case $CBN_EDITCHANGE ;- User types an entry
$gaInputTrap[14] = True
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _HiWord( $pvParam )
Return BitShift( $pvParam,16 )
EndFunc
Func _LoWord( $pvParam )
Return BitAND( $pvParam,0xFFFF )
EndFunc
Func _ButtonHandler()
;- cmdCancel is always enabled
;- cmdReset is enabled when one field has data
;- cmdOkay is enabled when all fields have data
If GUICtrlRead( $txtStation ) > "" AND GUICtrlRead( $txtUser ) > "" AND GUICtrlRead( $txtItem ) > "" AND GUICtrlRead( $txtScrap ) > "" AND GUICtrlRead( $cboReason ) > "" Then
GUICtrlSetState( $cmdOkay, $GUI_ENABLE )
Else
GUICtrlSetState( $cmdOkay, $GUI_DISABLE )
EndIf
If GUICtrlRead( $txtStation ) > "" OR GUICtrlRead( $txtUser ) > "" OR GUICtrlRead( $txtItem ) > "" OR GUICtrlRead( $txtScrap ) > "" OR GUICtrlRead( $cboReason ) > "" Then
GUICtrlSetState( $cmdReset, $GUI_ENABLE )
Else
GUICtrlSetState( $cmdReset, $GUI_DISABLE )
EndIf
EndFunc
Func _ResetFields()
;- Station
GUICtrlSetData( $cboStation, "" )
_GUICtrlComboBox_AddString( $cboStation, "" )
$pesfwk.MoveFirst
While NOT $pesfwk.EOF
_GUICtrlComboBox_AddString( $cboStation, $pesfwk( "Statno" ).Value )
$pesfwk.MoveNext
WEnd
$pesfwk.MoveFirst
$pesfwk.Find( "Netid = '" & @ComputerName & "'" )
If NOT $pesfwk.EOF Then $gcRealStation = $pesfwk( "Statno" ).Value
_GUICtrlComboBox_SelectString( $cboStation, $gcRealStation )
$pesfwk.Find( "Statno = '" & GUICtrlRead( $cboStation ) & "'" )
If NOT $pesfwk.EOF Then
GUICtrlSetData( $txtStation, $pesfwk( "Descrip" ).Value )
Else
GUICtrlSetData( $txtStation, "" )
EndIf
;- User
_ResetUserList()
; GUICtrlSetData( $cboUser, "" )
; _GUICtrlComboBox_AddString( $cboUser, "" )
; $syuuser.MoveFirst
; While NOT $syuuser.EOF
;  _GUICtrlComboBox_AddString( $cboUser, $syuuser( "Userid" ).Value )
;  $syuuser.MoveNext
; WEnd
; _GUICtrlComboBox_SelectString( $cboUser, "" )
; GUICtrlSetData( $txtUser, "" )
;- Item
GUICtrlSetData( $txtItem, "" )
GUICtrlSetData( $txtItmdesc, "" )
GUICtrlSetData( $cboLoctid, "" )
;- Material
GUICtrlSetData( $txtScrap, "" )
GUICtrlSetData( $cboReason, "" )
If GUICtrlRead( $cboStation ) > "" Then
_GUICtrlComboBox_AddString( $cboReason, "" )
$pesfmc.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "' AND Descrip <> 'Default GL code'" ;- Build new list
If NOT $pesfmc.EOF AND NOT $pesfmc.BOF Then
$pesfmc.MoveFirst
While NOT $pesfmc.EOF
_GUICtrlComboBox_AddString( $cboReason, $pesfmc( "Descrip" ).Value )
$pesfmc.MoveNext
WEnd
_GUICtrlComboBox_SetCurSel( $cboReason, 0 ) ;- Set to first in list
EndIf
$pesfmc.Filter = ""
EndIf
EndFunc
Func _ResetUserList()
GUICtrlSetData( $cboUser, "" )
_GUICtrlComboBox_AddString( $cboUser, "" )
If GUICtrlRead( $cboStation ) > "" Then
$pesfwk.Filter = "Statno = '" & GUICtrlRead( $cboStation ) & "'" ;- Build user list for this station
If NOT $pesfwk.EOF AND NOT $pesfwk.BOF Then
$pesfwk.MoveFirst
$x = StringSplit( $pesfwk( "Users" ).Value, "," )
If $x[1] > "" Then
For $i = 1 To $x[0]
_GUICtrlComboBox_AddString( $cboUser, $x[$i] )
Next
EndIf
EndIf
$pesfwk.Filter = ""
EndIf
_GUICtrlComboBox_SelectString( $cboUser, "" )
GUICtrlSetData( $txtUser, "" )
EndFunc

;--------------------------------------------------------------------------------------------------------------------
; Unused and/or programming code
;--------------------------------------------------------------------------------------------------------------------
#region
#cs
#ce
#endregion

I assume you are running this as a compiled script (.exe) which is why you receive line -1 only

There are multiple objects being created, and you might be able to find out which are failing by installing autoit3 and running the script directly from the scite4autoit editor.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

John,

My apologies for the long post. I will be sure to use the quote abilities next time. I will install the autoit3 and see if there is more i can figure out. Is there anything in specific i should be looking for? Again, i have no programming experience, so this is very foreign to me.

Thank you again for the reply.

Link to comment
Share on other sites

]>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3"
+>15:14:26 Starting AutoIt3Wrapper v.2.0.3.0    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/  CPU:X64 OS:X64)
- Skipping #AutoIt3Wrapper_UseAnsi directive because ANSI is not supported anymore.
>Running AU3Check (1.54.19.0)  from:C:Program Files (x86)AutoIt3
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(34,26) : ERROR: Opt() called with illegal argument 1: "colorMode"
Opt( "colorMode",     0 )
~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(260,85) : WARNING: $ES_AUTOHSCROLL: possibly used before declaration.
Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(260,100) : WARNING: $ES_READONLY: possibly used before declaration.
Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL, $ES_READONLY )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(263,94) : WARNING: $WS_VSCROLL: possibly used before declaration.
Global $cboUser = GUICtrlCreateCombo( "", 40, 140, 100, 30, BitOR( $CBS_DROPDOWN, $WS_VSCROLL,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(278,81) : WARNING: $ES_UPPERCASE: possibly used before declaration.
Global $txtItem = GUICtrlCreateInput( "", 40, 280, 560, 60, BitOR( $ES_UPPERCASE,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(319,28) : WARNING: $WM_COMMAND: possibly used before declaration.
GUIRegisterMsg( $WM_COMMAND,
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(602,51) : WARNING: $EN_KILLFOCUS: possibly used before declaration.
      Case $EN_KILLFOCUS ;- User moves off control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(604,45) : WARNING: $EN_CHANGE: possibly used before declaration.
      Case $EN_CHANGE ;- User types an entry
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(618,69) : WARNING: $EN_UPDATE: possibly used before declaration.
      Case $EN_UPDATE ;- User types an entry (handle before showing)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(260,85) : ERROR: $ES_AUTOHSCROLL: undeclared global variable.
Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3 - 2 error(s), 8 warning(s)
!>15:14:26 AU3Check ended.rc:2
>Exit code: 0    Time: 0.346

John,

Im not sure if i did this correctly, if you can advise, id really appreciate it. I ran the SciTE4AutoIt3 program... opened the script... and then chose --> Tools -->SyntaxCheckProd

Is this correct, and if so, does this show you anything that might be causing the error?

Thanks again

Edited by shealy06
Link to comment
Share on other sites

I don't know what that is. If you press the F5 key, your script should run, and it will stop with error

just as the .exe did, but this time will provide correct line number and nature of the error in the console.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

corsafsAutomationMX4Shop FloorAutoItMaterial Consumption Input.au3(260,85) : ERROR: $ES_AUTOHSCROLL: undeclared global variable.
Global $txtStation = GUICtrlCreateInput( "", 40, 90, 600, 30, BitOR( $ES_AUTOHSCROLL,
Looks like (and please correct me if im wrong) that there are 2 errors in the script. I pressed F5 and yes, it did generate errors in the bottom console. Here are the two errors (there were also 8 warnings)

Link to comment
Share on other sites

Add these below the other includes:

#include <WindowsConstants.au3>

#include <GUIConstantsEx.au3>

#Include <GuiComboBox.au3>

#Include <GuiEdit.au3>

Also, remove the line: Opt("colorMode", 0) ;- RGB

Then I'm getting these errors:

$prodata.Open("Provider=vfpoledb.1;Data Source=T:ERPProdata.dbc")

$prodata.Open("Provider=vfpoledb.1;Data Source=T:ERPProdata.dbc")^ ERROR

I don't have a T: drive on my computer, so you'll have to report from there...

Edited by dpryan
Link to comment
Share on other sites

For the error shown, you need to add

#include <EditConstants.au3>

Where you see the rest of the includes.

The warnings are important too, as they are more likely to be the cause of your error.

Although I'm no expert in errors or warnings, its always best to post the whole console output

so someone who is can better help.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

The environment in which this originally ran has obviously changed in the past 4+ years. In order to fix what you have shown, I suggest that you download the AutoIt version it was written in (3.2.2.0): http://www.autoitscript.com/autoit3/files/archive/autoit/ , then run the script from SciTe using that version.

You should get the valuable data you need in your specific work environment to either fix your issue specifically, or to have others be able to offer you something on what the issue could be.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...