[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

Creating and loading an SQL query using VBA on Access 2007

Hi Everyone,

I'm looking to create and load a sql query upon page load using VBA on Access 2007.  The query is a very simple query:

Select *
from TB1
Where TB1.CIF = '5000000'

 Is this doable and if so, can someone please help me by giving me a pseudo code?

Your help is greatly appreciated.

Thanks!
0
sarah_siu
Asked:
sarah_siu
  • 3
  • 3
2 Solutions
 
IrogSintaCommented:
Do you want this to be the recordsource of the form?  If so you could just add
Select * from TB1 Where TB1.CIF = "5000000" to the form's RecordSource property.  Or if you wanted to do it by code, in the form's OnLoad event, you would use:
Me.RecordSource = "Select * from TB1 Where TB1.CIF = '5000000'"

Open in new window

0
 
sarah_siuAuthor Commented:
Thanks Irogsinta.  I tried using your code in the code builder for my form.  It accepted the code fine but no data is displayed after I refresh the page...
0
 
IrogSintaCommented:
You do have bound textboxes in your form, right?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
sarah_siuAuthor Commented:
I have nothing on my form.  it's a completely blank slate...
0
 
IrogSintaCommented:
Sounds like you're not that familiar with Access.  In your case, why not try selecting your table in the Navigation pane on the left and then use one of the form wizards to help you.
Create Form
0
 
sarah_siuAuthor Commented:
You learn something new everyday.  Thanks for the quick turnaround and help!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now