How to run a query from a form

davidg47

Registered User.
Local time
Today, 04:46
Joined
Jan 6, 2003
Messages
59
I have a query that I wrote that searches several tables for an employees work ID number. The query works GREAT! But now I want to build a form with a search button that when clicked will run the query and if it finds the employee in any of the tables, it will return the requested fields on the form. If it doesn't find anything, it will send a MsgBox that says "Not Found!"

Any ideas on how to go about this?

Is this even the right place for me to ask this question?

Thanks,
David
 
Create a function that opens up a recordset with your SQL and retrieves the data. Can you post you SQL? what is then name of your form and textbox?
 
OK, here is the Query that I have been running from the Query Analyzer in SQL Server 2000. I now want to build a form that will run this query by clicking on a Search button on the form. If it finds the ID Number, then it will populate the fields I have requested in the Query... if it doens't, it will return a MsgBox saying, "Not Found!"


SELECT companyname, locationcode, locationdesc, statecode
FROM master1800flowers
WHERE ID = '111';
SELECT companyname, locationcode, locationdesc, statecode
FROM master24hourfitness
WHERE id = '222';
SELECT companyname, locationcode, locationdesc, statecode
FROM masteracmebrick
WHERE id = '333';
SELECT companyname, locationcode, locationdesc, statecode
FROM masteraep
WHERE id = '444';
SELECT companyname, locationcode, locationdesc, statecode
FROM masterallied
WHERE id = '555'

I do not know how to create a function that opens a recordset.

Thanks so much for your help...
D
 
I am using MSAccess as the front end to a SQLServer2000 DB. And as you know, the tables are reflected in the tables when you open Access.
 
The tables in my MS Access application are linked to tables in SQL Server 2000.
 

Users who are viewing this thread

Back
Top Bottom