Dim strDatabase As String
Dim strUsername As String
Dim strPassword As String
Dim strServer As String
Dim objINIFile As cInifile
Dim strMfgDate As Date
'inititate new object
Set objINIFile = New cInifile
On Error GoTo Form_Load_Error
'Locate ini file and receive databasename/Username and Pwd
objINIFile.Path = App.Path & "\GOPALS.ini"
objINIFile.Section = "DataBase Parameters"
objINIFile.Key = "SERVER"
strServer = objINIFile.Value
objINIFile.Key = "DatabaseName"
strDatabase = objINIFile.Value
objINIFile.Key = "USERNAME"
strUsername = objINIFile.Value
objINIFile.Key = "PASSWORD"
strPassword = objINIFile.Value
txtEdit.ZOrder
txtEdit = ""
set_title_caption ' set title caption for MSFLex
enlarge_grid ' Enlarge the grid to fit detail
If Time > Format(CDate("06:30:00"), "HH:MM:SS") Then
lbldate = (Format(Now - 1, "MMM DD, YYYY"))
Else
lbldate = (Format(Now, "MMM DD, YYYY"))
End If
strMfgDate = lbldate ' assign the label date to a variable
lbltime = Time 'assign time to label
Tmrclock.Interval = 1000
Tmrclock.Enabled = True
MSFlexReview.FillStyle = 0 'format individual cells
txtEdit.Visible = False
DTStartDate = Now - 3 'Display start date
DTEnddate = DTStartDate + 7
'Opens Subroutine - connection to SQL with the values received from the ini file
Call OpenConnection(strServer, strUsername, strPassword, strDatabase)
Exit Sub
Private Sub DisplayResults()
'Declare variable
On Error GoTo Display_Result_Error
Dim IntCounter As Integer
Dim objCmd As ADODB.Command
Dim PrmBeginDate As ADODB.Parameter
Dim PrmEndDate As ADODB.Parameter
Dim startDate As Date
Dim endDate As Date
startDate = DTStartDate.Value
endDate = DTEnddate.Value
'Set counter to zero
IntCounter = 0
Set ObjRsFlex = New Recordset
Set objCmd = New ADODB.Command
objOcn.CursorLocation = adUseClient
ObjRsFlex.LockType = adLockBatchOptimistic
With objCmd
.ActiveConnection = objOcn
.CommandType = adCmdStoredProc
.CommandText = "SP_ReviewScale_Transactions"
.Parameters.Append .CreateParameter("@beginningDate", adDBDate, adParamInput, , Format(DTStartDate.Value, "yyyy-mmm-dd"))
.Parameters.Append .CreateParameter("@EndingDate", adDBDate, adParamInput, , Format(DTEnddate.Value, "yyyy-mmm-dd"))
End With
'Populate grid with search results and set # rows to
'equal the # records returned by the search
Set ObjRsFlex = objCmd.Execute
If ObjRsFlex.RecordCount > 0 Then
IntCounter = IntCounter + 1 'Reserves first row for column headers
MSFlexReview.Rows = IntCounter + 1 'Adds a row for next record
While Not ObjRsFlex.EOF
With MSFlexReview
.Row = 0
.AddItem ObjRsFlex.Fields("Event_DateTime") & vbTab & ObjRsFlex.Fields("Operator_Badge") & vbTab & ObjRsFlex.Fields("Operator_Lastname") & vbTab & ObjRsFlex.Fields("Pallet_ID_Number") & vbTab & ObjRsFlex.Fields("Product_Code") & vbTab & ObjRsFlex.Fields("Product_description") & vbTab & ObjRsFlex.Fields("Product_Gross_Weight") & vbTab & ObjRsFlex.Fields("NET_WEIGHT")
End With
ObjRsFlex.MoveNext
Wend
Else
MsgBox " There is no records to populate the Grid."
End If
'clean objects
Set objCmd = Nothing
Set PrmBeginDate = Nothing
Set PrmEndDate = Nothing
Exit Sub
Display_Result_Error:
Call frmscan.ShowError("Error - in procedure Form_Load of Form frmscan")
End Sub