|
-
May 24th, 2012, 06:31 PM
#7
Thread Starter
Addicted Member
Re: FlexGrid Color Row, Saving DAT Files, Excel Spreadsheet Help!
This project has caused me an immense amount of frustration because I have to set up a different window kind of like the one he has here, but that's another story. The reason I'm referencing that is because he pointed me to a code that he said would do that for me, all I had to do was copy and paste and switch a few things around. But the code beat me. I'll post it below! Again, sorry for posting irrelevant information I'm still very beginner. Here is the code he presented to me:
Code:
Private Sub loadROList()
On Error Resume Next
Dim rsROList As ADODB.Recordset
Dim strSql As String
Dim nIndex As Integer
lngUnTouchedRos = 0
lngUsableRos = 0
lngNotUsableRos = 0
lngDuplicateRos = 0
fgROList.Clear (flexClearEverywhere)
fgROList.Rows = 0
fgROList.Cols = 15
fgROList.Rows = 1
fgROList.FixedRows = 1
fgROList.TextMatrix(0, 0) = "RO"
fgROList.TextMatrix(0, 1) = "UnTouched"
fgROList.ColDataType(1) = flexDTBoolean
fgROList.TextMatrix(0, 2) = "Usable"
fgROList.ColDataType(2) = flexDTBoolean
fgROList.TextMatrix(0, 3) = "NotUsable"
fgROList.ColDataType(3) = flexDTBoolean
fgROList.TextMatrix(0, 4) = "IsDuplicate"
fgROList.ColDataType(4) = flexDTBoolean
fgROList.TextMatrix(0, 5) = "RORating"
fgROList.Cell(flexcpBackColor, 0, 5, 0, 5) = vbRed
fgROList.ColComboList(5) = "#0;Excellent|#1;Good|#2;Bad "
fgROList.TextMatrix(0, 6) = "ShopID"
fgROList.TextMatrix(0, 7) = "Keywords"
fgROList.TextMatrix(0, 8) = "Year"
'fgROList.ColComboList(1) = "#0;NotUsable |#1;Usable |#2;UnTouched"
fgROList.TextMatrix(0, 9) = "Make"
fgROList.TextMatrix(0, 10) = "Model"
fgROList.TextMatrix(0, 11) = "Trim"
fgROList.TextMatrix(0, 12) = "Engine"
fgROList.TextMatrix(0, 13) = "Odometer"
fgROList.TextMatrix(0, 14) = "QC Completed"
nIndex = 1
strSql = "Select distinct RepairOrderNo,ROStatus,RORATING,ShopID,Keywords,ModelYear,Make,model,Trim,EngineDisplacementLiters,Odometer from [ROS$] WHERE RepairOrderNo <> 0 Order by RepairOrderNo "
Set rsROList = New ADODB.Recordset
rsROList.Source = strSql
rsROList.ActiveConnection = cnnRO
rsROList.Open
'rsROList.Fields.Append "XYX", adChar, 20
Do Until rsROList.EOF = True
fgROList.AddItem "", nIndex
fgROList.TextMatrix(nIndex, 0) = rsROList!RepairOrderNo
Select Case rsROList!ROStatus
Case "UnTouched"
fgROList.TextMatrix(nIndex, 1) = 1
lngUnTouchedRos = lngUnTouchedRos + 1
Case "Usable"
fgROList.TextMatrix(nIndex, 2) = 1
lngUsableRos = lngUsableRos + 1
Case "NotUsable"
fgROList.TextMatrix(nIndex, 3) = 1
lngNotUsableRos = lngNotUsableRos + 1
Case "Duplicate"
fgROList.TextMatrix(nIndex, 4) = 1
lngDuplicateRos = lngDuplicateRos + 1
End Select
fgROList.TextMatrix(nIndex, 5) = rsROList!RORATING
fgROList.TextMatrix(nIndex, 6) = rsROList!ShopID
fgROList.TextMatrix(nIndex, 7) = rsROList!Keywords
fgROList.TextMatrix(nIndex, 8) = rsROList!ModelYear
fgROList.TextMatrix(nIndex, 9) = rsROList!Make
fgROList.TextMatrix(nIndex, 10) = rsROList!Model
fgROList.TextMatrix(nIndex, 11) = rsROList!Trim
fgROList.TextMatrix(nIndex, 12) = rsROList!EngineDisplacementLiters
fgROList.TextMatrix(nIndex, 13) = rsROList!Odometer
If chkBlitZExist(rsROList!RepairOrderNo) = True Then
fgROList.TextMatrix(nIndex, 14) = chkQCCompleted(rsROList!RepairOrderNo)
Else
fgROList.TextMatrix(nIndex, 14) = "NoTip"
End If
'Select the BookMark
If strRepairOrder = rsROList!RepairOrderNo And strRepairOrder <> "" Then
fgROList.IsSelected(nIndex) = True
fgROList.ShowCell nIndex, 0
lngBookMarkRow = nIndex
loadRODetails (strRepairOrder)
If chkBlitZExist(strRepairOrder) = False Then
cmdOpenBlitZ.Enabled = False
Else
cmdOpenBlitZ.Enabled = True
End If
End If
nIndex = nIndex + 1
rsROList.MoveNext
Loop
If lngBookMarkRow <> 1 Then fgROList.IsSelected(1) = False
rsROList.Close
' rsROList.Fields.Append "XYX", adChar, 20
Set rsROList = Nothing
fgROList.AutoSize 0
fgROList.AutoSize 1
fgROList.AutoSize 2
fgROList.AutoSize 3
fgROList.AutoSize 4
fgROList.AutoSize 5
fgROList.AutoSize 6
fgROList.AutoSize 7
fgROList.AutoSize 8
fgROList.AutoSize 9
fgROList.AutoSize 10
fgROList.AutoSize 11
fgROList.AutoSize 12
fgROList.AutoSize 13
lblUsable.Caption = "Usable: " & CStr(lngUsableRos)
lblNotUsable.Caption = "Not Usable: " & CStr(lngNotUsableRos)
lblUntouched.Caption = "Untouched: " & CStr(lngUnTouchedRos)
lblDuplicate.Caption = "Duplicate: " & CStr(lngDuplicateRos)
End Sub
There is also another thing I came across that is the function he uses to save everything from that Flex Grid he already set up, if that makes sense. So maybe there is something in there that can help me save the color of the row I change also, here is that "save" code:
Code:
Private Sub subSaveRO()
Dim nIndex As Long
Dim strSql As String
On Error Resume Next
Set rsROList = New ADODB.Recordset
rsROList.ActiveConnection = cnnRO
rsROList.LockType = adLockOptimistic
'Dim cmdROList As New ADODB.Command
'Set cmdROList = New ADODB.Command
lblSave.Caption = "Please wait the Files is saving...."
For nIndex = 1 To fgROList.Rows - 1
If fgROList.TextMatrix(nIndex, 0) = "" Then Exit Sub
strSql = "Select * from [ROS$] WHERE RepairOrderNo = " & fgROList.TextMatrix(nIndex, 0)
rsROList.Source = strSql
rsROList.Open
Do Until rsROList.EOF = True
If fgROList.TextMatrix(nIndex, 1) = "1" Or fgROList.TextMatrix(fgROList.Row, 1) = "-1" Then 'UnTouched
rsROList!ROStatus = "UnTouched"
End If
If fgROList.TextMatrix(nIndex, 2) = "1" Or fgROList.TextMatrix(nIndex, 2) = "-1" Then 'Usable
rsROList!ROStatus = "Usable"
End If
If fgROList.TextMatrix(nIndex, 3) = "1" Or fgROList.TextMatrix(nIndex, 3) = "-1" Then 'NotUsable
rsROList!ROStatus = "NotUsable"
End If
If fgROList.TextMatrix(nIndex, 4) = "1" Or fgROList.TextMatrix(nIndex, 4) = "-1" Then 'Duplicate
rsROList!ROStatus = "Duplicate"
End If
rsROList!RORATING = fgROList.TextMatrix(nIndex, 5)
rsROList.Update
rsROList.MoveNext
Loop
rsROList.Close
Next
'Save the bookmark
Set rsBookMark = New ADODB.Recordset
rsBookMark.ActiveConnection = cnnRO
rsBookMark.LockType = adLockOptimistic
strSql = "Select * from [BookMark$] "
rsBookMark.Source = strSql
rsBookMark.Open
rsBookMark!RepairOrderNo = strRepairOrder
rsBookMark.Update
rsBookMark.Close
lblSave.Caption = ""
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|