how to activate visual basic code (1 Viewer)

sammers101

Registered User.
Local time
Today, 01:50
Joined
May 11, 2012
Messages
89
Basically what I'd like to do is delete my "old" table, copy my "new" table and rename it "old", then copy "blank new" and rename it to "new". Basically a big switcheroo, so I can enter new data into the blank table and compare with the most recent data.

So from what I've read I need to create a macro to call my VB code using run code
so if my visual basic code is VBcode
I just go into macro actions, run code and enter VBcode? Also, I'm pretty sure a few minutes ago I was able to name my VB code, and now they are all just Module1, Module2, Class1 etc.

Maybe that's not the problem at all, when I try to run the code from VB (using the green play button, a macro window pops up (with no macros listed)

My code I am using is so far is:
Code:
Option Compare Database

Public Function RenameTables()
DoCmd.DeleteObject acTable, "Old"

End Function
Thanks for always being so helpful!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 16:50
Joined
Jan 20, 2009
Messages
12,849
The whole strategy of copying an renaming tables is highly questionable especially since you appear to intend to be doing this repeatedly.

You can indicate the old and new data in one table and make comparisons without resorting to that.

You need to explain more about what you are doiing before you worry about the coding.
 

sammers101

Registered User.
Local time
Today, 01:50
Joined
May 11, 2012
Messages
89
I'm making a comparison to find any entries not on the new table that are on the old table. I then store the differences in a new table and eventually use that data. I think that is the only query that involves both tables.

If there is a better way to do that I'm all for it. I find myself switching around the tables every few days.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 16:50
Joined
Jan 20, 2009
Messages
12,849
Where does you data come from?

Typically imported data is held in a staging table kept for that purpose. It is cleared out or recreated on demand then the new import appended.

Comparisons can be then run against the existing data.

If the new data is coming from a form then new records are validated before being allowed in.

Few developers would ever rename a table in a production database. Even then it would be because they didn't know better.;)
 

sammers101

Registered User.
Local time
Today, 01:50
Joined
May 11, 2012
Messages
89
I copy and paste the data from turbolister, a program for ebay listings. It easily pastes into an access table.
No idea how to use a staging table. Any how to articles or anything you know of?
 

Users who are viewing this thread

Top Bottom