Results 1 to 1 of 1

Thread: Loading/Updating Flexgrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92

    Loading/Updating Flexgrid

    How do I update msflexgrid? I have been using Beacon's ADO tutorial and need some help with the msflexgrid. How do I load and update the grid? I have opened the rs and cn at form load().


    Also How can I get the SUM of LineTotal column and put it into a lable(lbltotal)?

    VB Code:
    1. Private Sub cmdAdd_Click()
    2. If txtAccount.Text = "" Then
    3. MsgBox "Must have an Account Number to start order"
    4. Exit Sub
    5. Else
    6.  
    7.  
    8. End If
    9. If txtQTY = "" Then
    10. MsgBox "Must have a Quantity to add to order"
    11. Exit Sub
    12. Else
    13. End If
    14.  
    15. With rsOrder
    16.         .AddNew
    17.           .Fields("Quantity") = txtQTY
    18.           .Fields("PartNumber") = txtPartNumber.Text
    19.           .Fields("Description") = txtDescription.Text
    20.         .Fields("Cost") = txtCost.Text
    21.         .Fields("OrderNumber") = txtOrderNumber.Text
    22.         .Fields("Linetotal") = txtCost * txtQTY
    23.         .Update
    24.       End With
    25.     Updatemsflexorder
    26.  
    27.      
    28.      
    29. End Sub
    30. Public Sub Updatemsflexorder()
    31.   Me.MousePointer = 11
    32.  
    33.    Set cnOrder = New ADODB.Connection
    34.    cnOrder.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    35.       "Data Source= c:\SMAOrder\orders.mdb"
    36.    cnOrder.Open
    37.    Set rsOrder = New ADODB.Recordset
    38.    Dim SQL As String
    39.    SQL = "SELECT Quantity,PartNumber,Description,Cost,LineTotal FROM Orders WHERE ordernumber=" & txtOrderNumber.Text
    40.    rsOrder.Open SQL, cnOrder
    41. MSFlexOrder.Redraw = False
    42.   With MSFlexOrder
    43.       .Clear
    44.       .Cols = 9
    45.       .ColWidth(0) = 800
    46.       .ColWidth(1) = 2000
    47.       .ColWidth(2) = 2600
    48.       .ColWidth(3) = 800
    49.       .ColWidth(4) = 800
    50.       .TextMatrix(0, 0) = "QTY"
    51.       .TextMatrix(0, 1) = "PartNumber"
    52.         .TextMatrix(0, 2) = "Description"
    53.         .TextMatrix(0, 3) = "Cost"
    54.         .TextMatrix(0, 4) = "LineTotal"
    55.        
    56.   .Rows = .FixedRows
    57.  
    58.   End With
    59.      
    60.    Do Until rsOrder.EOF
    61.         MSFlexOrder.AddItem Replace(rsOrder.GetString(, 1), vbCr, "")
    62.    Loop
    63.  
    64. MSFlexOrder.Redraw = True
    65.    MousePointer = vbDefault
    66.  
    67. End Sub
    Last edited by tarctor; Apr 10th, 2006 at 04:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width