How to change Form RecordSource?

G

Guest

I am having a bit of trouble getting a Form to change the RecordSource.

I have 2 Forms -- one is a Login Form, and the other is an Admin form for
administering data.

The user clicks on their respective name in the Login form (no pwd
required), and it should change the RecordSource on the Admin form to the
matching users' data set.

I set the following code behind the OnClick event:

Form_TestForm.RecordSource = "Table2"

And it doesn't change the dataset. I also tried this code:

Forms!USA.RecordSource = "USA_Jim"

And that also doesn't work...

Anyone have any ideas? I thought it was simple, and found out it wasn't!

Thanks
 
M

Marshall Barton

ChrisB said:
I am having a bit of trouble getting a Form to change the RecordSource.

I have 2 Forms -- one is a Login Form, and the other is an Admin form for
administering data.

The user clicks on their respective name in the Login form (no pwd
required), and it should change the RecordSource on the Admin form to the
matching users' data set.

I set the following code behind the OnClick event:

Form_TestForm.RecordSource = "Table2"

And it doesn't change the dataset. I also tried this code:

Forms!USA.RecordSource = "USA_Jim"

And that also doesn't work...

Anyone have any ideas? I thought it was simple, and found out it wasn't!


Forms!USA.RecordSource = "USA_Jim"
should work as long as USA_Jim is the name of a table or
query.

Don't forget that the form USA must be open before you can
reference it.
 
G

Guest

Ah! That might be the problem. I'm trying to run the command before the Form
is open.

I'll give it a try tomorrow at work and see how it goes..

Thanks again!

-Chris
 
G

Guest

I tried this out, and it worked perfectly!!

Just had to make it change the source AFTER the form loaded/opened.

Thanks!
 

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