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!
sarah_siuAsked:
Who is Participating?
 
IrogSintaConnect With a Mentor Commented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
sarah_siuAuthor Commented:
I have nothing on my form.  it's a completely blank slate...
0
 
IrogSintaConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.