Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 43
  1. #16
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    this is NOT The answer..


    query1

    Code:select name from tblStudents where gender = 'Male';

    query2
    Code:select name from tblStudents where gender = 'Female';

    query3

    Code:select name from q1
    union
    select name from q2;


    you will always get all fields from tblStudent.
    my code.. see * means all fields.
    strSQL = "Select * from tblData "

    if you wanted male in this case your combo box for gender would have (All) , male, female
    if the combo box was selected to Male then the code would generate

    Select * from tblStudent where gender = 'Male'

    change the recordsource and requery the sub form.

    if you wanted male and female leave the combo to (All) and the code would return

    Select * from tblStudent
    change the record source and requery the sub from.

    thats why I said you would make the fields that you wanted to filter combo boxes to have the All option and individual options.. if you wanted compound options then you use a list box and make it multiselct make them into a in() clauses.

    This is not hard it is just time consuming to do.

    hope this helps

  2. #17
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Thanks Alcapps. I am not sure that would work for me because I need to be able to basically run to queries from separate buttons from the same table and the same control criteria but have the lumped together in the same subform.

    Currently a user can already selected All for sex and get both male and female but I need to give them the option to run there query for just males but then add females after if they wanted.

  3. #18
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    Ok good luck.

  4. #19
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Thanks. Sorry if that is what you are trying say the code does. I mean I can code a button like 1/2 the time correct. So for me to understand even the basic functions of the code would be a miracle. Sorry but thanks for the attempted help.

  5. #20
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    I guess the concept of copying gender of male and the later replacing the data with gender is all. Not understanding why u can't remove the old (male)records and then copy the all records of(male+female) doesn't work. You get all in a new query for output.
    I do hope you figure out what you need to do. This website is here to help you get past your sticking points with examples to help. I just think you have a lot of studying to tackle this project.

  6. #21
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Thanks for the help and tips. I keep trying to think out of the box. Couldn't I have the subform display a blank table and then a search button to append table and then a add button to append it again? Is there a opposite of append like unappend?

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Simplistic examples of SQL actions executed in VBA code:

    CurrentDb.Execute "INSERT INTO tablename(fieldname1, fieldname2, etc) VALUES(value1, value2, etc)"

    CurrentDb.Execute "DELETE FROM tablename"

    The DELETE can include WHERE clause if selective delete is desired.
    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.

  8. #23
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Thanks June I am going to work with it when I get home. I take it I can link this code to a button to remove/add criteria to a table.

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Yep, button Click event is one.
    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.

  10. #25
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    I guess my point is you don't need a table. you will only be duplicating data in your database. Just use a query to pull the data into a subform. create a query on the fly and update the record source and requery subform and you have your data refreshed every time.

  11. #26
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Although I accommodated your question with an answer, I agree with al that 'temp' table should not be needed just to filter records.
    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.

  12. #27
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Ugh why do you say so? Will it be kinda janky or just processor heavy? I have looked and I can't seem to find an option for a remove from existing subform query I really wish I could.

  13. #28
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You don't 'remove', you requery. User reselects filter criteria and then clicks button to apply the new criteria.

    Yes, probably processor heavy, especially with large datasets. It's just klunky and doesn't really take advantage of the power of relational database queries.

    In addition to the example in my database, here is another poster's effort at creating a search/filter form https://www.accessforums.net/program...tes-31832.html
    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.

  14. #29
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    As always thank June I am going to look into it.

  15. #30
    MondayLon676767 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    19
    Quote Originally Posted by alcapps View Post
    I guess my point is you don't need a table. you will only be duplicating data in your database. Just use a query to pull the data into a subform. create a query on the fly and update the record source and requery subform and you have your data refreshed every time.
    I do have that or maybe I am misunderstanding what you are saying.

    I have a form, with criteria controls at the top below that is a subform which displays a query when a requery button is clicked. I can set the criteria and then click the requery button and the table refreshes to display data that matches the criteria controls and then I can change it and requery display people that match the new criteria. I got that but what I want to do is allow people to run a query with the requery button and then change the criteria and click a different button that would add the new data matches to the already existing query.

    Just like when you append a table with a query. Hence why I thought I could have the subform display a table that could be made with one button and then appended by another. The thing is I have spent a lot of time and everything works perfect now besides the lack of add/remove buttons that I described but I do not want to do it the wrong way or a way that is less efficient. The last thing I want to do is finish everything and then have to break it open shortly later because of a problem made now.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-02-2012, 04:35 PM
  2. Replies: 1
    Last Post: 01-31-2012, 11:54 AM
  3. Adding columns to existing tables.
    By OrangePie in forum Access
    Replies: 1
    Last Post: 07-07-2011, 01:49 PM
  4. Adding records to existing table
    By Mclaren in forum Programming
    Replies: 5
    Last Post: 05-18-2011, 12:44 PM
  5. Replies: 3
    Last Post: 11-02-2010, 10:15 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