I made a program that the user can enter an item per row, however if the row is already 15 rows above the system is already hanging/lagging/freezing the user needs to wait a minute to process the additional item.
I don't know what's wrong with my program.
I'm using Vsflexgrid, do you think because of the control that I'm using?

Name:  ito.jpg
Views: 506
Size:  40.1 KB

Code:
Private Sub stogrid_AfterEdit(ByVal Row As Long, ByVal Col As Long)
On Error GoTo X
Call SearchUOM(checkStringValue(UnQuote(stogrid.Cell(flexcpText, stogrid.Row, 1))), UnQuote(stogrid.Cell(flexcpText, stogrid.Row, 3)), stogrid.Row)

If stogrid.Row = stogrid.Rows - 1 And stogrid.TextMatrix(stogrid.Row, 3) <> "" Then
End If

Dim issuedby As String


If checkFG(stogrid.TextMatrix(stogrid.Row, 1), stogrid, stogrid.Row) = True Then
MsgBox "FG is already in list!", vbCritical, "Double Entry is not allowed"


stogrid.Cell(flexcpText, Row, 1) = ""
stogrid.Select stogrid.Row, 1

Exit Sub
End If
If stogrid.Cell(flexcpText, Row, 1) = "" Then
stogrid.Select stogrid.Row, 1
Else
Call SearchFG(checkStringValue(UnQuote(stogrid.Cell(flexcpText, Row, 1))), stogrid.Row)
End If


If stogrid.Row = stogrid.Rows - 1 And stogrid.TextMatrix(stogrid.Row, 1) <> "" Then
stogrid.Select stogrid.Row, 4
End If


If stogrid.Row >= 1 And stogrid.Col = 4 And stogrid.TextMatrix(stogrid.Row, 4) <> "" Then
    For i = 1 To stogrid.Rows - 1
    If Trim(checkinventory(stogrid, issuedby)) <> Empty Then
        itm = Split(checkinventory(stogrid, issuedby), "-")

                MsgBox "Cannot transfer item: " & stogrid.TextMatrix(itm(0), 4) & " because it has less inventory", vbCritical, "Less Inventory"
                   stogrid.Cell(flexcpText, itm(0), 4) = stogrid.TextMatrix(itm(0), 5)
                   stogrid.Select itm(0), 4, itm(0), 4
                        stogrid.EditCell
        Exit Sub
    End If
    Next
    'End If
End If
'End If
Dim rs As New ADODB.Recordset
Dim Y As Boolean
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient


If stogrid.TextMatrix(stogrid.Row, 4) <> "" And stogrid.TextMatrix(stogrid.Row, 8) <> "" Then

With stogrid
.Cell(flexcpText, .Row, 9) = stogrid.TextMatrix(.Row, 7) * stogrid.TextMatrix(.Row, 8)
.Cell(flexcpText, Row, 9) = Format(.TextMatrix(Row, 9), "###,###,###.#0")
rs.Open "SELECT Vatable FROM tbl_ItemMasterfile where ITEMCODE ='" & .TextMatrix(Row, 1) & "'", cn, 1, 3
If rs.RecordCount > 0 Then
Y = rs!Vatable

If Y = True Then
.Cell(flexcpText, .Row, 10) = Format(.Cell(flexcpText, .Row, 9) / 1.12, "###,###,###.#0")
Else
.Cell(flexcpText, .Row, 10) = .Cell(flexcpText, .Row, 9)
End If
End If
Call ComputeSalesTotal

End With

    stogrid.Select stogrid.Row, 4
Exit Sub
'End If
End If

X:



End Sub
Code:
Private Sub stogrid_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)


With stogrid

If Col = 3 Then
.ColComboList(3) = AllUom(UnQuote(stogrid.Cell(flexcpText, Row, 1)))

End If


End With


End Sub
Code:
Private Sub stogrid_CellChanged(ByVal Row As Long, ByVal Col As Long)
On Error GoTo X:
Dim ti As String
Dim um As String
   
With stogrid
    If Col = 3 Or Col = 4 Then
        Dim COST As Double
        
        If Trim(.TextMatrix(Row, 6)) <> Empty Then
            
            'pag hindi same ng uom
            If UCase(.TextMatrix(Row, 3)) = UCase(.TextMatrix(Row, 6)) Then
                    If Trim(.TextMatrix(Row, 4)) <> "" Then
                            .TextMatrix(Row, 7) = CDbl(.TextMatrix(Row, 4))
                    Else
                            .TextMatrix(Row, 7) = Trim(.TextMatrix(Row, 4))
                    End If

            
            Call SearchFG6(checkStringValue(UnQuote(stogrid.Cell(flexcpText, Row, 1))), stogrid.Row)
            

            
            
             Else
            
            
                    If Trim(.TextMatrix(Row, 4)) <> Empty Then
                            If IsNumeric(.TextMatrix(Row, 4)) = True Then
                                    Call SearchFG5(checkStringValue(UnQuote(stogrid.Cell(flexcpText, Row, 1))), stogrid.Row)
                                       If valuom > 0# Then
                                            Call GetValueUOM1(checkStringValue(UnQuote(stogrid.Cell(flexcpText, Row, 6))), stogrid.Row)
                                                If StandardUOM > 0# Then
                                                End If
                                            
                                            Call GetValueUOM2(checkStringValue(UnQuote(stogrid.Cell(flexcpText, Row, 3))), stogrid.Row)
                                                If StandardUOM2 > 0# Then
                                                End If
                                                
                                                .Cell(flexcpText, Row, 7) = CDbl(((StandardUOM) / (StandardUOM2))) * CDbl(.TextMatrix(Row, 4))
                                                .Cell(flexcpText, Row, 7) = Format(.TextMatrix(Row, 7), "###,###,###.##########0")
                                                
                                       Else
                                       
                                       
                                       
                                       End If
                                       

                            Else
                            
                            End If
                    Else
                        .Cell(flexcpText, Row, 9) = 0
                    End If
                        Me.lblTotal.Caption = getTotal(stogrid)
    
            End If
            
        End If
 
    End If
End With
   
   
   With stogrid

     If .Col = 4 Then
       .Editable = flexEDKbdMouse
     Else
      .Editable = False
     End If
  End With
X:
End Sub