How to change an ACCESS forms record source using code.

J

Jim

I am using ACCESS 2000 and would like to use code to
change the record source of a form. The form name is
frm_Main. The table that I would like to switch the
record source to is tbl_Temp1.

I have tried the following:

Forms!frm_Main.RecordSource = "tbl_Temp1"

I don't receive an error, but the record source is not
changed to tbl_Temp1

Jim
 
P

Paul Johnson

Forms!frm_Main.RecordSource = "SELECT * FROM tbl_Temp1"

You can certainly use a more elaborate SQL statement than the example, but
this will start with the table, straight and simple.

Paul
 
P

Paul Johnson

This is strange. In response to your original post, I ran a little test,
and it seemed that I couldn't just put a table name in for the RecourdSource
property (as a string value), but I could put in a SQL statement. That is
what prompted my reply. Now, after seeing Van's post, I had to check again,
and this time I WAS able to set the RecordSource property to the name of a
table. I can't figure what I goofed up, since the test was very simple and
straightforward, but I see that my response was off the track-- you don't
need to use a SQL statement. You can, if it will return the records you
want.

Sorry if I caused any confusion.

Paul
 

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