• Dcount (2k)

    Author
    Topic
    #412749

    My Quest in the Attch file.

    Viewing 1 reply thread
    Author
    Replies
    • #905307

      Try the following code in the Before Insert event of the form:

      Private Sub Form_BeforeInsert(Cancel As Integer)
      If DCount(“*”, “tbl2”) >= 50 Then
      MsgBox “Cannot add new record.”, vbInformation
      Cancel = True
      End If
      End Sub

      It works in my own test database; I cannot test it in your database, probably because you use an Arabic language system.

      • #905345

        it works with me good. thank u hans
        Ashraf

        • #905408

          another idea ;
          i have tblBuss contain bus no – seats .
          bus no 1 has 5 seats
          bus no 2 has 8 seats
          i want to add that in the entry of the former form ( when the user enter bus no not allow 5 seats in tblbuss ) .
          Ashraf

          • #905416

            You will have to use the Before Update event of the text box, and set Cancel = True if the condition is not met.

            If you want more detailed help, you will have to provide more detailed information.

            • #905436

              ur code work already but now i have another modify .
              i create tbl called buss the 1st bus has 5 seat 2nd has 10 seat …etc .
              i want when the user choose the bus no also clount the seats for evry bus and not allow more than the seats in tabl buss.
              ashraf

            • #905439

              Try this:

              Private Sub bus_no_BeforeUpdate(Cancel As Integer)
              If DCount("*", "tbl2", "[bus no] = " & Chr(34) & Me.[bus no] & Chr(34)) >= _
              DLookup("Seats", "tblBuss", "[bus no] = " & Chr(34) & Me.[bus no] & Chr(34)) Then
              MsgBox "Cannot select this bus.", vbInformation
              Cancel = True
              End If
              End Sub

            • #905460

              very good . thank u my dear .
              Ashraf

            • #905461

              very good . thank u my dear .
              Ashraf

            • #905440

              Try this:

              Private Sub bus_no_BeforeUpdate(Cancel As Integer)
              If DCount("*", "tbl2", "[bus no] = " & Chr(34) & Me.[bus no] & Chr(34)) >= _
              DLookup("Seats", "tblBuss", "[bus no] = " & Chr(34) & Me.[bus no] & Chr(34)) Then
              MsgBox "Cannot select this bus.", vbInformation
              Cancel = True
              End If
              End Sub

            • #905437

              ur code work already but now i have another modify .
              i create tbl called buss the 1st bus has 5 seat 2nd has 10 seat …etc .
              i want when the user choose the bus no also clount the seats for evry bus and not allow more than the seats in tabl buss.
              ashraf

          • #905417

            You will have to use the Before Update event of the text box, and set Cancel = True if the condition is not met.

            If you want more detailed help, you will have to provide more detailed information.

        • #905409

          another idea ;
          i have tblBuss contain bus no – seats .
          bus no 1 has 5 seats
          bus no 2 has 8 seats
          i want to add that in the entry of the former form ( when the user enter bus no not allow 5 seats in tblbuss ) .
          Ashraf

      • #905346

        it works with me good. thank u hans
        Ashraf

    • #905308

      Try the following code in the Before Insert event of the form:

      Private Sub Form_BeforeInsert(Cancel As Integer)
      If DCount(“*”, “tbl2”) >= 50 Then
      MsgBox “Cannot add new record.”, vbInformation
      Cancel = True
      End If
      End Sub

      It works in my own test database; I cannot test it in your database, probably because you use an Arabic language system.

    Viewing 1 reply thread
    Reply To: Dcount (2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: