I have a toolbar on an application that I use to refresh a flexgrid with different recordsets. Whenever I choose a different button on the toolbar its suppossed to change the columns and records in the flexgrid, however it always just stays the same, what am I missing?
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo errhandler
Select Case ButtonMenu.Index
Case 1
Dim strsql_size As String
Dim inti As Integer
Dim wasNull As Boolean
MSFItem.Clear
MSFItem.Rows = 2
MSFItem.FormatString = "^SKU |^QTY |^Size |^Color |^First Receive Date |^UPC "
strsql_size = "select a.sku_num, sum(a.avail_qty) qty, b.size_cd, b.color_des, b.first_rcv_dt, " & _
" d.upc_cd from gm_inv_loc a, gm_sku b, gm_itm c, gm_sku2upc_cd d" & _
" Where a.sku_num = b.sku_num And b.itm_cd = c.itm_cd And b.sku_num = d.sku_num" & _
" and c.itm_cd = '" & txtItemCode.Text & "' group by a.sku_num, b.size_cd, b.color_des, b.first_rcv_dt, d.upc_cd" & _
" order by a.sku_num"
Set rsmain_6 = New ADODB.Recordset
rsmain_6.Open strsql_size, cn, adOpenKeyset, adLockReadOnly
If rsmain_6.EOF Then
MsgBox "This item does not have any current inventory information.", vbCritical, "Error"
txtSOH.Text = ""
Exit Sub
Else
Do While Not rsmain_6.EOF()
If MSFItem.TextMatrix(1, 0) = "" Then
inti = 1
Else
inti = MSFItem.Rows
MSFItem.Rows = MSFItem.Rows + 1
End If
wasNull = False
MSFItem.TextMatrix(inti, 0) = rsmain_6("sku_num")
MSFItem.TextMatrix(inti, 1) = rsmain_6("qty")
MSFItem.TextMatrix(inti, 2) = IfNull(rsmain_6("size_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 3) = IfNull(rsmain_6("color_des"), wasNull, "")
MSFItem.TextMatrix(inti, 4) = IfNull(rsmain_6("first_rcv_dt"), wasNull, "")
MSFItem.TextMatrix(inti, 5) = IfNull(rsmain_6("upc_cd"), wasNull, "")
For i = 1 To MSFItem.Rows - 1 Step 2
MSFItem.Row = i
For j = 0 To MSFItem.Cols - 1
MSFItem.Col = j
MSFItem.CellBackColor = &HC0FFFF
Next j
Next i
rsmain_6.MoveNext
Loop
End If
Exit Sub
Case 2
Dim strsql_store As String
'Dim inti As Integer
'Dim wasNull As Boolean
MSFItem.Clear
MSFItem.Rows = 2
MSFItem.FormatString = "^Item code |^QTY |^Store Code |^District Code |^Store Name |^Square Footage "
strsql_store = "select a.itm_cd, sum(c.avail_qty) qty, c.store_cd, d.op_dist_cd, d.store_name, " & _
" d.sq_ft from gm_itm a, gm_sku b, gm_inv_loc c, store d" & _
" Where a.itm_cd = b.itm_cd And b.sku_num = c.sku_num and c.store_cd = d.store_cd" & _
" and a.itm_cd = '" & txtItemCode.Text & "'" & _
" group by a.itm_cd, c.store_cd, d.op_dist_cd, d.store_name, d.sq_ft"
Set rsmain_7 = New ADODB.Recordset
rsmain_7.Open strsql_size, cn, adOpenKeyset, adLockReadOnly
If rsmain_7.EOF Then
MsgBox "This item does not have any current inventory information.", vbCritical, "Error"
txtSOH.Text = ""
Exit Sub
Else
Do While Not rsmain_7.EOF()
If MSFItem.TextMatrix(1, 0) = "" Then
inti = 1
Else
inti = MSFItem.Rows
MSFItem.Rows = MSFItem.Rows + 1
End If
wasNull = False
MSFItem.TextMatrix(inti, 0) = rsmain_7("itm_cd")
MSFItem.TextMatrix(inti, 1) = IfNull(rsmain_7("qty"), wasNull, "")
MSFItem.TextMatrix(inti, 2) = IfNull(rsmain_7("store_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 3) = IfNull(rsmain_7("opt_dist_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 4) = IfNull(rsmain_7("store_name"), wasNull, "")
MSFItem.TextMatrix(inti, 5) = IfNull(rsmain_7("sq_ft"), wasNull, "")
For i = 1 To MSFItem.Rows - 1 Step 2
MSFItem.Row = i
For j = 0 To MSFItem.Cols - 1
MSFItem.Col = j
MSFItem.CellBackColor = &HC0FFFF
Next j
Next i
rsmain_7.MoveNext
Loop
End If
Exit Sub
Case 3
Dim strsql_sku As String
'Dim inti As Integer
'Dim wasNull As Boolean
MSFItem.Clear
MSFItem.Rows = 2
MSFItem.FormatString = "^SKU |^Size |^Color |^First Receive Date |^UPC "
strsql_sku = "select a.sku_num, sum(a.avail_qty) qty, b.size_cd, b.color_des, a.store_cd, d.store_name, d.op_dist_cd, d.sq_ft," & _
" b.size_cd, b.color_des from gm_inv_loc a, gm_sku b, gm_itm c, store d" & _
" Where a.sku_num = b.sku_num And b.itm_cd = c.itm_cd And a.store_cd = d.store_cd" & _
" and c.itm_cd = '" & txtItemCode.Text & "' group by a.sku_num, b.size_cd, b.color_des, a.store_cd," & _
" d.store_name , d.op_dist_cd, d.sq_ft, b.size_cd, b.color_des" & _
" order by a.store_cd, a.sku_num"
Set rsmain_8 = New ADODB.Recordset
rsmain_8.Open strsql_size, cn, adOpenKeyset, adLockReadOnly
If rsmain_8.EOF Then
MsgBox "This item does not have any current inventory information.", vbCritical, "Error"
txtSOH.Text = ""
Exit Sub
Else
Do While Not rsmain_8.EOF()
If MSFItem.TextMatrix(1, 0) = "" Then
inti = 1
Else
inti = MSFItem.Rows
MSFItem.Rows = MSFItem.Rows + 1
End If
wasNull = False
MSFItem.TextMatrix(inti, 0) = rsmain_8("sku_num")
MSFItem.TextMatrix(inti, 1) = rsmain_8("qty")
MSFItem.TextMatrix(inti, 2) = IfNull(rsmain_8("size_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 3) = IfNull(rsmain_8("color_des"), wasNull, "")
MSFItem.TextMatrix(inti, 4) = IfNull(rsmain_8("store_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 5) = IfNull(rsmain_8("store_name"), wasNull, "")
MSFItem.TextMatrix(inti, 5) = IfNull(rsmain_8("op_dist_cd"), wasNull, "")
MSFItem.TextMatrix(inti, 5) = IfNull(rsmain_8("sq_ft"), wasNull, "")
For i = 1 To MSFItem.Rows - 1 Step 2
MSFItem.Row = i
For j = 0 To MSFItem.Cols - 1
MSFItem.Col = j
MSFItem.CellBackColor = &HC0FFFF
Next j
Next i
rsmain_8.MoveNext
Loop
End If
Exit Sub
'Case Else
End Select
errhandler:
MsgBox "Errors occured while retreiving the item information" & vbCrLf & "Please Click on Reset Button and Redo the process" & vbCrLf & Err.Number & ":" & Err.Description, vbCritical, "Error"
Exit Sub
End Sub