Changing the table linked to a form

J

Jason Walter

How can I change a form to use a different table or query. I can do it
in the SQL view for a query, but I don't see that with the form.

Thanks
Jason
 
B

Bruce M. Thompson

How can I change a form to use a different table or query. I can do it
in the SQL view for a query, but I don't see that with the form.

Assuming the alternate table/query contains the same fields that the form
controls are bound to:

**With the form in Design view, on the property sheet, find the "Record Source"
property and select the query/table from the list or enter (or generate, using
the Build [...] button on the right of the Property's field) the SQL statement.

**If using VBA ...

Me.Recordsource = "qryMyQuery"
.... or ...
Me.Recordsource = "MyTableName"
.... or, if another form ...
Forms("MyFormName").Recordsource = "MyTableName"

.... and, if you have a specific SQL statement you want to use in place of an
object name, simply assign that instead:

Forms("MyFormName").Recordsource = _
"SELECT * FROM MyTableName"

Setting the Recordsource property via VBA way will cause the form to
automatically requery, so there is no need to add a line in your code to force
it to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top