UBGrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WhiteShore
    New Member
    • Nov 2007
    • 44

    #16
    Originally posted by QVeen72

    How many rows are there in Grid..?
    What is the PK of the table..?
    There are 5 rows in the grid.
    And as for note when the grid consist of 1 item data only (then it become 1 row only), the script works very well.
    It will show "subscript out of range" when there are more than 1 itemdata (row).

    I've tried the code and it still save first row itemdata only (while there are 5 itemdata) *sad*

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #17
      Hi,

      What is the PK of Sales table...?

      Regards
      Veena

      Comment

      • WhiteShore
        New Member
        • Nov 2007
        • 44

        #18
        Originally posted by QVeen72
        Hi,

        What is the PK of Sales table...?

        Regards
        Veena
        Forgive me, what PK is?

        Comment

        • lotus18
          Contributor
          • Nov 2007
          • 865

          #19
          Originally posted by WhiteShore
          Forgive me, what PK is?
          PK means "Primary Key"

          Comment

          • WhiteShore
            New Member
            • Nov 2007
            • 44

            #20
            Originally posted by lotus18
            PK means "Primary Key"
            I see..
            it's SO_No
            it can be find at txtnoso.text

            Comment

            • QVeen72
              Recognized Expert Top Contributor
              • Oct 2006
              • 1445

              #21
              Hi,

              Thats your answer..
              Your table has PrimaryKey ..
              PK cannot be repeated,
              and you are putting in a loop and try to add, the same PK.
              obviously, it doesnt add..you will get error

              Either Make a Composite PK , or else, remove PK and make some other field as PK..

              In such conditions, (SalesNo + SlNo ) together will be the PK..

              REgards
              Veena

              Comment

              • WhiteShore
                New Member
                • Nov 2007
                • 44

                #22
                Dear Ms. Veena,
                i've remove PK from Sales table, and i dont use any PK for now.
                but when i run the program it still has the same problem.
                it only save the first row item data and then "subscript out of range".

                Comment

                • QVeen72
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1445

                  #23
                  Hi,

                  How many Columns your grid has..?
                  How have you declared variable "i"...?
                  Post your Table Structure..


                  Regards
                  Veena

                  Comment

                  • WhiteShore
                    New Member
                    • Nov 2007
                    • 44

                    #24
                    There are 4 columns in the grid.
                    Col:
                    1 -> Item's id
                    2 -> Item's name
                    3 -> Qty
                    4 -> "b" as checkbox

                    Yup i had declared "i" as integer.

                    Table structure:
                    1. SO_No
                    2. PO_No
                    3. Date
                    4. CustomerID
                    5. ItemID
                    6. Qty

                    Comment

                    • WhiteShore
                      New Member
                      • Nov 2007
                      • 44

                      #25
                      it's to complicated, isnt it? =(
                      i've tried to change the validation so it will be : only save the cols(3) that is not NULL.

                      [CODE=vb]If cboSales.Text = "" Then
                      MsgBox "Choose Sales No!"
                      Else
                      With rs
                      .ActiveConnecti on = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=salesdb. mdb;Persist Security Info=False"
                      .CursorLocation = adUseClient
                      .LockType = adLockOptimisti c
                      .CursorType = adOpenStatic
                      .Source = "SELECT * FROM Sales"
                      .Open

                      For i = 1 To MSFlexGrid1.Row s - 2

                      If Not MSFlexGrid1.Tex tMatrix(i, 3) < 1 Then
                      .AddNew
                      .Fields(0).Valu e = txtNoSO.Text
                      .Fields(1).Valu e = cboSales.Text
                      .Fields(2).Valu e = dtDate.Value
                      .Fields(3).Valu e = cboCust.Text
                      .Fields(4).Valu e = MSFlexGrid1.Tex tMatrix(i, 0) 'item name
                      .Fields(5).Valu e = MSFlexGrid1.Tex tMatrix(i, 3) 'item qty
                      .Update
                      End If
                      Else
                      MsgBox "Please insert a valid qty!"
                      End If

                      Next
                      End With
                      End If[/CODE]

                      For that code, if cols(3) consists of NULL value then it will stop working, where there're still others value that is not null.

                      Did i make a wrong validation?

                      Comment

                      • lotus18
                        Contributor
                        • Nov 2007
                        • 865

                        #26
                        Originally posted by WhiteShore
                        it's to complicated, isnt it? =(
                        i've tried to change the validation so it will be : only save the cols(3) that is not NULL.

                        [CODE=vb]If cboSales.Text = "" Then
                        MsgBox "Choose Sales No!"
                        Exit Sub
                        Else
                        With rs
                        .
                        .
                        .
                        .
                        I had just added Exit Sub. : )

                        Rey Sean

                        Comment

                        • WhiteShore
                          New Member
                          • Nov 2007
                          • 44

                          #27
                          Originally posted by lotus18
                          I had just added Exit Sub. : )

                          Rey Sean
                          Dear Mr. Rey Sean,
                          Thanks for your reply, but it doesn't make any change, because what i want to validate is it msflexgrid of colums(3).

                          Comment

                          • QVeen72
                            Recognized Expert Top Contributor
                            • Oct 2006
                            • 1445

                            #28
                            Hi,

                            Change the checking to :

                            If Val(MSFlexGrid1 .TextMatrix(i, 3)) > 0 Then


                            Regards
                            Veena

                            Comment

                            • WhiteShore
                              New Member
                              • Nov 2007
                              • 44

                              #29
                              Originally posted by QVeen72
                              Hi,

                              Change the checking to :

                              If Val(MSFlexGrid1 .TextMatrix(i, 3)) > 0 Then


                              Regards
                              Veena
                              I've change it and it works but it only save 1 itemdata instead of 5.
                              Do i need to make a looping? but how?

                              Comment

                              • QVeen72
                                Recognized Expert Top Contributor
                                • Oct 2006
                                • 1445

                                #30
                                Hi,

                                Keep a BreakPoint on first line and debug,
                                and check if it passes through the"IF" condition and goes to ".AddNew" ..
                                (For all 5 rows)
                                If it is not passing, then the Value of the Grid for that row, is Blank/NIL

                                If it is passing, then PK has not been removed..


                                Regards
                                Veena

                                Comment

                                Working...