Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Posts
    22

    Unanswered: Access Counter when adding data /records -use Dcount?

    Hi all, please help. I have a counter which is working when making bookings however i want it to count per "ClientID" , it must pop a message and still continue taking other bookings, for other people. e.g. If I make a booking for John Doe, the booking will run till the third booking and only pop a message saying "maximum bookings made". Same must happen with other users. In other words it counts per user id not by overall bookings.If Peter made 1 and John made 2 bookings - the message must not pop up although 1 + 2 = 3. The message must only pop up for Peter once he reaches 3 and for John on his 3rd booking as well. I hope you will help me here. Again thanks for your help.See attached screenshots

    Here is my current code - where do i stick the client id,appointment table, etc

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If RecordsetClone.RecordCount = 2 Then
    MsgBox "Maximum bookings made."
    End If
    End Sub

    Private Sub Form_Current()
    If RecordsetClone.RecordCount = 2 Then
    Me.AllowAdditions = True
    Me.AllowEdits = False
    End If
    End Sub
    Attached Thumbnails Attached Thumbnails AppointmentTable.JPG   ClientTable.JPG   counterperclient.JPG  

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Instead of:
    Code:
    If RecordsetClone.RecordCount = 2 Then
    Try:
    Code:
    If DCount("*", "<TableName>", "ClientID = " & Me.ClientID.Value) = 2 Then
    Where:
    1. <TableName> is the name of the table (or the query) that is used as the form RecordSource.
    2. Me.ClientID is a reference to a control (or a field) that uses ClientID as its ControlSource (i.e. it is bound to the ClientID column of the table).
    Have a nice day!

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Also where ClientID is defined as a Number or Autonumber Datatype!

    If ClientID should happen to be defined as a Text Datatype, then instead of

    "ClientID = " & Me.ClientID.Value

    the correct syntax would be

    "ClientID = '" & Me.ClientID.Value & "'"

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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