Results 1 to 7 of 7
  1. #1
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21

    Access Counter when adding data /records -use Dcount?

    Hi all, please help with Dcount. 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 ClientTable.JPG   AppointmentTable.JPG  

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    Is the form filtered to show only a single users records? If so, the RecordsetClone method should work.

    Include the ID in the DCount WHERE CONDITION.

    If DCount("ClientID", "table name", "ClientID=" & Me.ClientID) = 2 Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    Hi , See attached, please look at the two issues here.

    1. I want it to count number of bookings made under appointments, once a client makes more than 2 booking then pop up window must say " Client made enough bookings and now qualifies for free voucher"
    2. The search button does not return any results.
    Thanks
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    I presume the form involved is AppointmentInformation. I entered 3 bookings in a row for the same client. The third booking triggered the free voucher message.

    Under what condition does client qualify for voucher? Two bookings made in the same day? Or if one booking last week and second booking this week? What about 3, 4, 5 bookings? Or is this for only exactly 2 bookings over any period?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    June7 thanks for your help.
    Client qualify for voucher after "every "3 bookings, and booking can be made anytime, the counter must keep track. After the third booking then it must reset the counter and that specific client now starts from scratch, from 1 till 3. I need this code please. Thanks again

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    Instead of BeforeUpdate, try AfterUpdate:

    Private Sub Form_AfterUpdate()
    If DCount("ClientID", "Appointments", "ClientID=" & Me.ClientID) Mod 3 = 0 Then
    MsgBox "Client made enough bookings and now qualifies for free voucher."
    End If
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    Thanks June7, This resolved my issue. Keep it up...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access 2007 Dcount
    By BeitersIT in forum Access
    Replies: 1
    Last Post: 04-21-2012, 01:20 PM
  2. Replies: 3
    Last Post: 12-19-2011, 11:18 AM
  3. Replies: 10
    Last Post: 01-10-2011, 07:52 PM
  4. stop access from auto adding records
    By svcghost in forum Forms
    Replies: 2
    Last Post: 10-21-2010, 05:25 PM
  5. Adding Records
    By Rick West in forum Forms
    Replies: 7
    Last Post: 05-17-2010, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums