Results 1 to 4 of 4
  1. #1
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22

    MessageBox Based on Recordset Count

    I have a form that, among other data, includes a text field called "position number" that identifies each of many positions in our organization.



    Most of our positions have only one person assigned to it, however, there are a few that have multiple people assigned. When the form is opened (based on the position number), if there is more than one person assigned to the position number, I'd like to give my users a quick warning message: "There is more than one person assigned to this position", or something similar. Just to give them a heads up.

    Can something like this be done with a macro or only with VBA? With my limited background, I'm not sure how the "count" a recordset behind a form.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Many ways. One way, although quite a slow command, is to use Dlookup.

    Such as
    Dim CountP AS Integer
    CountP=DLookUp("Count(people)","tablename","Positi on=" & positionnumber)
    MsgBox "There are " & CountP & "People for this position"

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    How can multiple bodies occupy the same position? Job sharing? I understand many people can have same job description but a position should have only one person.

    You can use DCount function in a textbox or in VBA code or in a query.

    In textbox ControlSource have expression like:
    =DCount("[position number]", "[tablename]", "[position number]='" & [position number] & "'"

    Is [position number] a text datatype? If it is not, remove the apostrophe delimiters.
    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.

  4. #4
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Thanks guys. Both suggestions work great! Yes, some positions sharing common characteristics use the same position description, and thus, the same number. I wanted my users to be reminded of those conditions when they apply. Thanks again.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-23-2012, 12:28 AM
  2. Replies: 11
    Last Post: 12-21-2011, 09:48 AM
  3. messagebox help :D
    By imintrouble in forum Forms
    Replies: 2
    Last Post: 10-20-2011, 01:50 PM
  4. Count IIf based on records above and below
    By William McKinley in forum Queries
    Replies: 19
    Last Post: 09-17-2010, 04:49 PM
  5. Make a messagebox
    By carstenhdk in forum Queries
    Replies: 7
    Last Post: 05-18-2010, 06:18 AM

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