Very basic Visual Basic 
Author Message
 Very basic Visual Basic

I have reason to rename 25 tables within a single A2k mdb on a regular
basis. I have written a macro to do this with individual 'renames', but as
the new name varies from time to time I have to change each statement in the
macro to reflect this. What I want is a macro that runs a VBA module,
because I can change the VB code in a fraction of the time.

The renaming code I will work on myself, but I would like to know what code
wraps around this to enable me to access and rename table names. Do I use
'Private Sub/End Sub'? And what about DoCMD, where does that fit in?

I know it's a basic question but I *can* program to some extent. I once
learned REXX (any mainframers remember that?) from the online help files but
it took me weeks to actually run any code because I didn't know each module
had to begin with /* */  !!!

I'd appreciate a kickstart!

Terry



Wed, 26 Dec 2001 03:00:00 GMT  
 Very basic Visual Basic
I have reason to rename 25 tables within a single A2k mdb on a regular
basis. I have written a macro to do this with individual 'renames', but as
the new name varies from time to time I have to change each statement in the
macro to reflect this. What I want is a macro that runs a VBA module,
because I can change the VB code in a fraction of the time.

The renaming code I will work on myself, but I would like to know what code
wraps around this to enable me to access and rename table names. Do I use
'Private Sub/End Sub'? And what about DoCMD, where does that fit in?

I know it's a basic question but I *can* program to some extent. I once
learned REXX (any mainframers remember that?) from the online help files but
it took me weeks to actually run any code because I didn't know each module
had to begin with /* */  !!!

I'd appreciate a kickstart!

Terry



Wed, 26 Dec 2001 03:00:00 GMT  
 Very basic Visual Basic
Tezza, the kickstart i recommend is to find some other way of doing whatever
it is you need to do that makes you waht to rename all of your tables. while
renaming the tables can certainly be done using VBA, it will create chaos
with everything else in your application. queries, forms, reports, macroes,
other vba code would all potentially have to be changed as well.

perhaps if you could describe why you feel your tables need to be renamed
from time to time, someone could offer a more viable solution.

--
make a nice day,
TomG
Tampa, FL


Quote:
> I have reason to rename 25 tables within a single A2k mdb on a regular
> basis. I have written a macro to do this with individual 'renames', but as
> the new name varies from time to time I have to change each statement in
the
> macro to reflect this. What I want is a macro that runs a VBA module,
> because I can change the VB code in a fraction of the time.

> The renaming code I will work on myself, but I would like to know what
code
> wraps around this to enable me to access and rename table names. Do I use
> 'Private Sub/End Sub'? And what about DoCMD, where does that fit in?

> I know it's a basic question but I *can* program to some extent. I once
> learned REXX (any mainframers remember that?) from the online help files
but
> it took me weeks to actually run any code because I didn't know each
module
> had to begin with /* */  !!!

> I'd appreciate a kickstart!

> Terry



Wed, 26 Dec 2001 03:00:00 GMT  
 Very basic Visual Basic
I am running files through a few databases using queries to add other
information while sorting records on the way and further dividing a large
table into 25 smaller ones. The output is put to one side and another file
is sent through the system. The 25 output files always have the same name. I
won't create a new 'process' for every input file, rather I use a single
'template' which has the queries/macros etc already written for one specific
range of table names.

Just now I saved a macro as code (now why didn't I remember that earlier?!),
which I can now run from a macro, but which I can now quickly edit with
Ctrl+H. The code looks way heavier than it should be, but it may just be the
kickstart I need!

Thanks anyway TOM

FAI
Why the multiple postings? I had my clock set one year ahead (dunno why that
happened), and OE would not post a future message. Changed the date and
tried several more times to no avail, so I deleted the old one created in
2000 and created a new one, which flew like the wind, carrying the ghost of
e-mails future in its wake



Wed, 26 Dec 2001 03:00:00 GMT  
 Very basic Visual Basic
Tezza, do you know the new name of each table?
if yes, you can get old names from msysobjects table and create a recordset
where to get new names.
So with a Do until eof ...loop you can rename table by table.
be careful: you have to remove all the relationships for each table and after
rebuild them.
Does it help you? if not I'm sorry if is not so clear for me the second part of
your request!
bye
Davide
Quote:

> I have reason to rename 25 tables within a single A2k mdb on a regular
> basis. I have written a macro to do this with individual 'renames', but as
> the new name varies from time to time I have to change each statement in the
> macro to reflect this. What I want is a macro that runs a VBA module,
> because I can change the VB code in a fraction of the time.

> The renaming code I will work on myself, but I would like to know what code
> wraps around this to enable me to access and rename table names. Do I use
> 'Private Sub/End Sub'? And what about DoCMD, where does that fit in?

> I know it's a basic question but I *can* program to some extent. I once
> learned REXX (any mainframers remember that?) from the online help files but
> it took me weeks to actually run any code because I didn't know each module
> had to begin with /* */  !!!

> I'd appreciate a kickstart!

> Terry



Sat, 05 Jan 2002 03:00:00 GMT  
 Very basic Visual Basic
Davide, I like that idea. I'll look further into msysobjects. There are no
relationships so I don't have to worry about that.

The tablenames I will be changing are always going to be the same, they also
have a numeric suffix (01 to 25). What I was hoping for was something like
this (with tables T01 to T25 being renamed S01 to S25)

some opening control statements

Assign variable a = 1
Do until a = 25
rename table T&a [to] S&a
a=a+1
end

Don't ask me what kind of frankenstein code that is! It's merely to
illustrate my point far better than I've done up to now! And yes I noticed
that I have not taken into account the leading zero's in table names below
10, damn.

Please don't spend a lot of time on this anybody, the converted macro does
work after all!

Regards,
Terry


Quote:
> Tezza, do you know the new name of each table?
> if yes, you can get old names from msysobjects table and create a
recordset
> where to get new names.
> So with a Do until eof ...loop you can rename table by table.
> be careful: you have to remove all the relationships for each table and
after
> rebuild them.
> Does it help you? if not I'm sorry if is not so clear for me the second
part of
> your request!
> bye
> Davide


> > I have reason to rename 25 tables within a single A2k mdb on a regular
> > basis. I have written a macro to do this with individual 'renames', but
as
> > the new name varies from time to time I have to change each statement in
the
> > macro to reflect this. What I want is a macro that runs a VBA module,
> > because I can change the VB code in a fraction of the time.

> > The renaming code I will work on myself, but I would like to know what
code
> > wraps around this to enable me to access and rename table names. Do I
use
> > 'Private Sub/End Sub'? And what about DoCMD, where does that fit in?

> > I know it's a basic question but I *can* program to some extent. I once
> > learned REXX (any mainframers remember that?) from the online help files
but
> > it took me weeks to actually run any code because I didn't know each
module
> > had to begin with /* */  !!!

> > I'd appreciate a kickstart!

> > Terry



Sat, 05 Jan 2002 03:00:00 GMT  
 Very basic Visual Basic

Quote:

> Davide, I like that idea. I'll look further into msysobjects. There are no
> relationships so I don't have to worry about that.

> The tablenames I will be changing are always going to be the same, they also
> have a numeric suffix (01 to 25). What I was hoping for was something like
> this (with tables T01 to T25 being renamed S01 to S25)

> some opening control statements

> Assign variable a = 1
> Do until a = 25
> rename table T&a [to] S&a
> a=a+1
> end

> Don't ask me what kind of frankenstein code that is! It's merely to
> illustrate my point far better than I've done up to now! And yes I noticed
> that I have not taken into account the leading zero's in table names below
> 10, damn.

> Please don't spend a lot of time on this anybody, the converted macro does
> work after all!

'********
Public Sub Rename_Tables()

Dim indx As Integer

For indx = 1 to 25
    DbEngine(0)(0).TableDefs("T" & Format(indx,"00")).Name = "S" & Format(indx,
"00")
Next indx

End Sub
'*********

Simply replace "T" with your starting table prefix and "S" with your ending
table prefix.  (keeping the quotation marks)  The format statement takes care of
the zero-padding to 2 places.

Simply call this code from wherever.  A Macro works (RunCode action)

--
HTH
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|  gHaD (Aaron Robinson) | Microsoft MVP [Access] |
| MJM-PC Solutions, Inc. |Web & Database Developer|
|       Chicago, IL      |   Will work for Dew?!  |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Sat, 05 Jan 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Learning Basic - Visual Basic - Visual InterDev

2. Very basic Visual Basic help required

3. Basic/Visual Basic Consultants Available

4. BASIC, VISUAL BASIC, C++, DELPHI SOFTWARE FRO CHEAP PRICE

5. Quick Basic/Visual Basic source code

6. Basic Visual Basic/Macro questions

7. PLEASE HELP A NEWBIE! (Some basic Visual Basic questions)

8. do Visual Basic 6.0 and Visual Basic .NET version beta Working Both

9. Difference between Visual Basic 6 and Visual Basic.Net

10. Visual basic 4 to Visual basic 6

11. Visual Basic 3.0 to Visual Basic 6.0

12. Visual Basic 5 vs. Visual Basic 6

 

 
Powered by phpBB® Forum Software