SELECT statement using VBA?

noidentity29

New member
Local time
Yesterday, 17:45
Joined
Dec 14, 2009
Messages
2
I have spent a little more time than I would like to admit trying to get Access to select data from a table. The 'FindRecord' functionality is not working correctly. Access is pulling back all of the data and then filtering it. I need to optimize this and I thought it would be best to write the code myself.

The DoCmd.RunSQL only runs Actioin commands (Insert, Update, etc). I tried the DoCmd.OpenSQL and it opened a spreadsheet. I need to return the dataset to a form just as the default behavior of 'FindRecord' does.

Is this possible? How should I approach this?
 
maybe set the recordsource of the form to the query or statement you want, then open the form?
 
You use the docmd.runsql when you want to execute a sql command, such as Delete (Delete button on form for example). The
The Select function is for gathering a set of records based on certain criteria, and then using it as the basis of a form or report, such as building a report showing people with Surname of 'Jones'.

As Adam said, set the recordsource to your select statement..

On your load method something like this would work
Me.RecordSource = "SELECT * FROM myTable"
 

Users who are viewing this thread

Back
Top Bottom