I have developed a database that keep the records of my client's hardwares and softwares. I created a form with a button against a textbox that will filter my records if a particular company name in typed. How should I call my sql query to display all the information related to any company name typed?
how to call my Query from VB code
Collapse
X
-
First you would have your query reference the textbox as the criteria for the field you want filtered. You do this by entering the following in the criteria box for the field you want filtered:I would then recommend creating a form based on your query and open the form. This allows you to do more things with events, etc. The VBA code to open a form isCode:Forms!YourFormName!TextboxName
Code:DoCmd.OpenForm "YourFormNameHere"
-
@Seth Schrock don't understand this. Let me explain further the problem I am facing. My database has four forms, COMPANY,HARDWAR E,SOFTWARE and REPORT FILTER. My Query (Query1) displays the records from both hardware and software because there is referential integrity between the two. My Query go thusREPORT FILTER FORM consists of a button and textBox1. I want the button to trigger the Query1 event if clicked and display the record based on the company name supplied in textBox1.Code:SELECT HARDWARE.[COMPANY NAME], HARDWARE.DEVICE_ID, HARDWARE.[DEVICE TYPE], HARDWARE.[USER NAME], HARDWARE.PROCESSOR, HARDWARE.RAM, HARDWARE.[HARD DISK], HARDWARE.[DATE PURCHASED], HARDWARE.[LAST SERVICE DATE], HARDWARE.[IDENTIFIED PROBLEM], HARDWARE.STATUS, SOFTWARE.[SOFTWARE NAME], SOFTWARE.[DATE INSTALLED], SOFTWARE.[EXPIRING DATE], SOFTWARE.NETWORK FROM HARDWARE INNER JOIN SOFTWARE ON HARDWARE.DEVICE_ID = SOFTWARE.DEVICE_ID;
Comment
-
So to get your filter, you would add the following before the semi-colon at the end of your query:Code:WHERE HARDWARE.[COMPANY NAME] = Forms![Report Filter]!TextBox1
Comment
Comment