Results 1 to 8 of 8
  1. #1
    brianb is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    8

    Help Writing VBA and call to query

    I'm not a VBA expert, but I'm looking for some help to write VBA code and call that code to a query. I've done it once before a while back with some basic code but can't seem to remember how.



    What I'm wanting the code to do is basically replace a long IIF statement I would make in a query. So what I have is a list of about 35 items that I want to put into about 7 different groups.

    For example a couple of the items are: "Approval", "Approved", which I would want to make a group called Approved, and anything in my data that says "Approval" or "Approved" would be in that group. Some of the groups would only have 2 likes like just shown and some may have as many a 10 things. Can someone assist me w/this? Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You may want to look at a Select Case structure.

  3. #3
    brianb is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    8
    Ok, is there a sample I can look at or can someone assist in writing it?

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    the other problem with your post is the fact that you only said what you wanted grouped, but so what? A query displays data in a structure that you specify. Grouping records by groups based on criteria doesn't mean anything unless you specify how you want the output to look.

    for instance, I'm guessing that this:

    Code:
    approved
    approved
    approved
    approval
    approval
    approval
    approval
    approval
    would need to look something like this for you in an output:

    Code:
    TYPE OF RECORD	COUNT
    "approved"	8
    But see, the grouping is the first part of this. What good is a grouping if you don't know what to do with it? Or what you want done with it?

  5. #5
    brianb is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    8
    I want the output to show just the Group, I don't need the count of how many. So if I were to put it in an IIF statement it would look like this. IIF([table].[field] = "Approval", "Approval", IIF([table].[field] = "Approved", "Approval", ...)) were ... is just more IIF statements for other groups.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    show the board a sample dataset of 5 records, as you would expect it to look.

  7. #7
    brianb is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    8
    Sorry for the late repsonse, but below is a table of how I'd want this

  8. #8
    brianb is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    8
    Approval Received
    Approvals File Received
    Approved File Setup
    Approval New File
    File Review





    Sorry couldn't figure out how to copy the actualy table as you have above.

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

Similar Threads

  1. ComboBox writing to text
    By tmcrouse in forum Forms
    Replies: 1
    Last Post: 11-18-2010, 09:10 AM
  2. Writing Query Results to New Table
    By quigongrim in forum Queries
    Replies: 2
    Last Post: 08-23-2010, 09:04 AM
  3. Writing Access functions
    By new2access123 in forum Programming
    Replies: 5
    Last Post: 02-06-2010, 10:47 PM
  4. Replies: 4
    Last Post: 11-06-2009, 09:51 AM
  5. I need help writing a query statement
    By dking in forum Queries
    Replies: 1
    Last Post: 02-25-2009, 09:43 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