Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
SQL to Subform in DatsheetView
Shia G. 
   
3 years ago
How can I develop a dynamic Microsoft Access form that generates SQL statements based on user selections and displays the SQL results in a subform with Datasheet view? what are the steps in vba?
Shia G. OP  @Reply  
   
3 years ago

Kevin Yip  @Reply  
     
3 years ago
You can filter the subform's content based on the user's search entry.  In my example below, a short VBA procedure sets the Filter and FilterOn properties of the subform, allowing it to return movie titles containing the text "hallow".  This site should have videos on this.  You need to know about the AfterUpdate event also.  The filter's criteria also needs to be in SQL format.  Also, the use of "double single quotes" (or double double-quotes) inside the criteria is needed too.  All these topics are covered on this site.
Kevin Yip  @Reply  
     
3 years ago

Shia G. OP  @Reply  
   
3 years ago
thank you for your advice
but i want that the user (based on his selections) should be able to generate a sql that brings data from a few different tables, and only show that few fields that he selected, (filter is not enough for this),
i could make a sql of all the tables and filter only what he selected, but how can i hide all the the fields that he didn't select?
Kevin Robertson  @Reply  
          
3 years ago
Richard did something similar with a List Box in this video:

Custom List Box
Kevin Yip  @Reply  
     
3 years ago
On a datasheet, you can set each column's visibility with the .ColumnHidden property, based on user choices.  E.g.:

     Me.MovieTitle.ColumnHidden = False
     Me.MovieYear.ColumnHidden = True
     Me.MovieCountry.ColumnHidden = True
     Me.IMDbID.ColumnHidden = True
     Me.MovieTitle.DatePurchased = False
Kevin Yip  @Reply  
     
3 years ago
Regarding letting the user pick which columns to see, you may let them make the selections with checkboxes.  I rarely do this because (a) if there are lots of columns, which is usually why this is done, the user will have lots of checkboxes to look at; and (b) the user may not know what columns to choose and end up getting useless results.  For instance, if the filter is "MovieGenre = 'Drama'", and the user picks only the MovieGenre column, then he will see a column containing nothing but "Drama", hardly the useful data you want him to see.  You may consider having the columns picked for them.
Shia G. OP  @Reply  
   
3 years ago
Thanks Kevin and Kevin. I learned a lot today. one small question is there any techhelp video how to export the data of a listbox or datasheet to excel/PDF? (preferred using vba).
Richard Rost  @Reply  
          
3 years ago
What you want is the TransferSpreadsheet command, and I just looked... I'm surprised I haven't covered it in any Developer lessons yet. I'll have to remedy that. I know it's on my list. Someone a while back asked me another question about it. Video coming up soon...
Shia G. OP  @Reply  
   
3 years ago
Thank you Richard. Waiting for the Video
Dan Jackson  @Reply  
            
3 years ago
"Someone a while back asked me another question about it. Video coming up soon..."

That'll be me! If Adam can have Tempvars, I have spreadsheet transfers - More Exports!!!!
Scott Axton  @Reply  
        
3 years ago
Dan

I think Richard had to write a db just to manage his Question / Topic / Future Video list.
You do realize that Adam had to wait quite some time right?  Kind of like watching grass grow - you need to be in it for the long haul.
Scott Axton  @Reply  
        
3 years ago
Just like Orson Welles, who promised for Masson, said: "We will sell no wine before its time."


Edit:  
Ohhhh My god.  That makes me old.  I watched that commercial as a kid!
Dan Jackson  @Reply  
            
3 years ago
Oh yeah i know. That's why i'm jumping up and down now - Hoping to get something in the next 5 years or so (VIP treatment lol!)
Richard Rost  @Reply  
          
3 years ago
Awesome commercial. LOL

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 1:32:49 AM. PLT: 1s