Results 1 to 4 of 4
  1. #1
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67

    Automatically fill in field in a loop

    I'm hoping this could solve some speed problems in the group using my database.

    I have a team of three people which assign "leads" to the rest of my team via a combobox filled with usernames.



    I would like to have that field automatically populate by looping through the names in that combobox.

    Does anyone have some insight as to how I could do this?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Your question is not very clear, perhaps an example written out of what you are trying to accomplish?

  3. #3
    RachelBedi is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jul 2012
    Posts
    67
    hi rpeare, I am soon becoming the bane of your existence :-P thank you so much for your help!

    My bank folks have to verify account numbers for enrollments in our payment system - once the bank account has been verified it moves on to an activator who authenticates the business information. In order for an activator to see the company which the banker has verified, the banker has to "assign" it to an activator.

    Here are the fields for the bankers;

    Paymode ID, Company name, Date of Enrollment Bank Status, Assigned, Bank Modified Date

    The field "Assigned" is a drop down menu filled with the people who are considered "activators"

    Currently the banker who has verified the bank account has to physically go to that field and choose a name from the drop down menu, which is a) cumbersome and b) not nec. accurate (if they don't go down the list equally they might assign too many accounts to one person)

    I would like to autogenerate the "assigned" field by looping through the options in the list via vba code.

    I really hope that makes more sense, if not I can try to upload my form!

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Ok so your combo box with the list of activators is correctly showing WHO can possibly be assigned the task but you want to evenly distribute the workload over those 'activators' and pick the person with the lowest number of accounts to handle.

    So what you want is a 'suggested' activator (which presumably they can change if they want to).

    There are a couple of ways you can do this fairly easily. The first is to create a list box with a summary of your activators and how many current accounts they have so from your BANKERS table it would be a query something like

    SELECT Assigned, Count(Assigned) as AccountsActive FROM Bankers GROUP BY Assigned ORDER BY Count(Assigned) DESC

    Then in the ON CLICK event of the list box you would have

    ASSIGNED = Lst_AssignedList

    where ASSIGNED would be the name of your data entry field and Lst_AssignedList would be the name of the list box.

    Barring that you would have to do a little coding but it would be the same basic method

    in the ON ENTER property of your ASSIGNED combo box field

    Code:
    dim db as database
    dim rst as recordset
    dim sSQL as string
    
    set db = currentdb
    sSQL = "SELECT Assigned, Count(Assigned) as AccountsActive FROM Bankers GROUP BY Assigned ORDER BY Count(Assigned) DESC"
    set rst = db.openrecordset(ssql)
    rst.movefirst
    ASSIGNED = rst.fields("Assigned")
    rst.close
    
    set db = nothing
    basically you're opening up the same dataset as if you were going to do it in a list box, read the first value (the person with the lowest number of accounts) and fills in your ASSIGNED field with the id of that person.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-07-2012, 08:21 AM
  2. Replies: 4
    Last Post: 02-13-2012, 05:49 PM
  3. Replies: 7
    Last Post: 06-14-2011, 10:37 AM
  4. Replies: 5
    Last Post: 01-20-2011, 11:36 PM
  5. Replies: 2
    Last Post: 09-20-2010, 09:02 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