Results 1 to 6 of 6
  1. #1
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117

    Subform record count warning message


    I would like to show a Message box to an operator when a certain number of records have been reached in a subform e.g when 36 records have been entered I want a message to appear telling the operator that a certain report can then be raised. Can anyone offer some advice as to whether this is possible

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can do this a couple of ways, using a dcount function is probably the most common

    on your main form have a text box that is updated every time you add or remove a record from your subform. The syntax for the count query would be something like:

    [FieldOnMainForm] = Dcount("*", "SubFormTableName", "[MainFormFK] = " & [MainFormPK])

    if the PK on your main form is a number or

    [FieldOnMainForm] = Dcount("*", "SubFormTableName", "[MainFormFK] = '" & [MainFormPK] & "'")

    if the PK on your main form is a text value

  3. #3
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Not quite clear what MainFormFK and MainFormPK stand for ?
    Also, how do I then get the message to appear once the count reaches a specific number ?
    Thanks for the reply

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    PK is Primary Key, FK is foreign key.

    So let's say your main form is called Frm_Main, Your subform is called Frm_Sub, the table holding your data for the subform is Tbl_Sub, the foreign key of that table is Main_FK (this is the field that would be linking your main and subforms), and the field containing the primary key to your main form is Main_PK your formula would look like

    [FieldonMainForm] = Dcount("*", "Tbl_Sub", "[Main_FK] = " & [MainPK])

  5. #5
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    OK I understand that - where do I add this code ? and how do I then link it to a message box?

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're doing data entry in your subform itself you can put it in the code in your AFTER UPDATE event or ON EXIT of the last field of your subform. If you're using some other method to add data to your subform (an update or append query instead of doing data entry on the subform) you would add it to the code that does the append/update. You don't need to link it to anything if you put it in your code, it would be an unbound text box.

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

Similar Threads

  1. Access Warning Message
    By marksnwv in forum Access
    Replies: 1
    Last Post: 06-01-2012, 01:46 PM
  2. Make Table Warning Message
    By cassidym in forum Queries
    Replies: 1
    Last Post: 03-16-2011, 10:12 AM
  3. Warning Message for Missed Date
    By maintt in forum Access
    Replies: 2
    Last Post: 07-23-2010, 09:05 AM
  4. Access warning message
    By John Southern in forum Access
    Replies: 2
    Last Post: 05-28-2010, 06:01 AM
  5. Records deleted with NO warning message.
    By evanscamman in forum Access
    Replies: 2
    Last Post: 12-14-2007, 11:18 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