I want the initial Query to be from VBA Code

S

Sam

I am developing an access application, the first time a I load a form
data is retireved from the base query. I deally i would want to change
this so that the form loads with and dispals data from VBA code (my
query will be in VBA). How do I go about doing this? I have tried to pu
the code on the on load and open form but it still doesnt work.

Your help will be apprecited.

Regards,
 
C

Cheryl Fischer

The following will work in the On Open event of a form:

Me.RecordSource = "Select * from [MyTable] where [MyTable].[LastName] = "
& Chr(34) & "Smith" & Chr(34)

You have not posted your code, so we cannot comment ... However, you might
want to take the SQL portion of it and run it directly as a query (outside
of the form) to see if it returns records.
 
Top