making a new database with diff name and opening it

A

axeman

basically i have a database already created the way I like now I want to make
it more user friendly for me

I want to open my database and then copy or maybe save as to create a new
file but the new file name i want to be made up from user input like a drop
down to make a date so new file name would be 101005.mdb
as in 10/10/05 and then be using that database, so close the original
database so it always stays the same.
 
J

John Vinson

basically i have a database already created the way I like now I want to make
it more user friendly for me

I want to open my database and then copy or maybe save as to create a new
file but the new file name i want to be made up from user input like a drop
down to make a date so new file name would be 101005.mdb
as in 10/10/05 and then be using that database, so close the original
database so it always stays the same.

Ummm...

WHY!?

Storing data in fieldnames is a bad idea. Storing data in table names
is even worse. Storing data in the name of the .mdb file is *even
worse yet*. If you want to keep backups of your data - as of course
you should! - simply use a good backup utility to make a backup daily,
or write a small .BAT file to make a daily copy of the database.

John W. Vinson[MVP]
 
A

axeman422

I actually didn't think the why was important in this forum but ok I'll go
into more detail.
I have created a database which I want to use in a way like a template. The
funtionality works exactly the way I want it to but I use forms to change
values in tables and so on. I want to be able to save the changes I made into
a ew .mdb file so that the name has a reference to when I created it without
me actually having to use the menu and save as. I also want to leave the
original .mdb file in tact,the way it was originally so that I can open it
again and create another .mdb file with a different name and change all the
same tables I changed before.

So my question still remains the same
I have read you can use
FileCopy "C:\test.txt", "C:\test2.txt"

in vb but I dont want the name to be set in vb I want the name to be made by
user interface ie. txt box or listbox If I could set the value for the
test2.txt (using a form)then I can do exactly what I want to do.
 
L

Larry Daugherty

When people in the newsgroup see a question that asks something strange
about a product they know so well, they ask "Why"? just in case someone is
headed in a terribly wrong direction and really needs guidance. For what
it's worth, John Vinson is one of the best. He gives a lot of help in the
newsgroups and often answers questions that no one else will. He has the
patience of a saint and is unfailingly polite. Other than that, he's just
like the rest of us. :)

For what you are trying to go to some trouble to automate, what do you gain
over simply copying the target mdb, renaming the copy and opening it?

I rarely differ with John but in this case, I do. It makes sense to me that
you might have lots of similar copies of an MDB in the same project folder,
each copy named for a significant date.

HTH
 
A

axeman422

I didn't mean any disrespect by my last post. I have been using access for
about a week now, the project I am working on will hopefully bring in a bit
of money for me so I am hesitant to tell everyone why I want certain things.
Basically I want it all to be automated no clicking on file for the user no
naming a new file no copy no paste no save as, I want it all done in the
background. I don't want the user to click on anything except what is in the
forms I have created. Fromn what I have learned so far I can use the filcopy
and open the new file and close the old 1 without any drama, but the part I
am having problems with is the naming of the new file I don't want it to be
set to a constant in vb, I want it to be able to change depending on the user
interface on a form.

I can set all the user interface no worries and have it all put into a table
so the value I want the new file to be is all there it's just making the
copyfile to look to the table for the new name.
 
J

John Vinson

Basically I want it all to be automated no clicking on file for the user no
naming a new file no copy no paste no save as, I want it all done in the
background. I don't want the user to click on anything except what is in the
forms I have created.

That's what I don't understand: why you want to copy the database AT
ALL. A Database is not (usually) treated like a document; it's a
container, an environment for tables of data, queries, reports, forms
and so on. The user will typically add, edit, sometimes delete data
within the tables; all of these changes are instantly and
automatically saved to disk within the database, as they move from
record to record. In NONE of my applications is it necessary for a new
copy of the database (other than routine backups, which are handled
outside of Access) to be saved to disk.

I think I now understand *what* you're trying to do. What I'm
struggling with is *why*.


John W. Vinson[MVP]
 
J

John Vinson

So my question still remains the same
I have read you can use
FileCopy "C:\test.txt", "C:\test2.txt"

Just FWIW, you can also use

strNewFilename = Me!txtFileName ' get the text from a form control
FileCopy "C:\Test.txt", "C:\" & strNewFilename & ".txt"

Note also that a .txt file *is not a database*. I presume you're
actually copying a (closed, don't ever copy an open database!) .mdb
file? The same program logic would apply.

However see my other post in this thread.

John W. Vinson[MVP]
 
A

axeman422

the .txt was just an example but thank you for your help I wasn't sure if I
could add a string into it or not.
 
A

axeman422

works perfectly thanks john and larry

John Vinson said:
Just FWIW, you can also use

strNewFilename = Me!txtFileName ' get the text from a form control
FileCopy "C:\Test.txt", "C:\" & strNewFilename & ".txt"

Note also that a .txt file *is not a database*. I presume you're
actually copying a (closed, don't ever copy an open database!) .mdb
file? The same program logic would apply.

However see my other post in this thread.

John W. Vinson[MVP]
 
A

axeman422

This has been very helpful for me in more ways then 1. Not only did I use it
in the db in the way I wanted to but it also has given me a new streamlined
way of making new databases.
I created a database for just the purpose backing up the 1 I am working on
with name made up of dates and such from the combo box I mentioned before
then I open the database I am currently working on goes something like this

Private Sub cmdstart_Click()
Dim strNewName As String
strNewName = Me!txtnewname

FileCopy "C:\db\table9.mdb", "C:\db\" & strNewName & ".mdb"

Call Shell("C:\Program Files\Microsoft Office\Office\msaccess.exe
C:\db\table9.mdb", 1)
End Sub

It opens another access and opens with the database I'm working on atm named
table9. Then when I feel like making a new backup I just save it close it the
first db comes back up change name and away I go again

makes backing up very easy and since I work on 1 db for days even weeks
creating it the way I want, it helps me alot

so again thx guys
 
¹

¹¢Óñ´ä

ÍøÂ繤³Ìʦ¿¼ÊÔ·ÑÓýµµÍÁË
axeman422 said:
I actually didn't think the why was important in this forum but ok I'll go
into more detail.
I have created a database which I want to use in a way like a template. The
funtionality works exactly the way I want it to but I use forms to change
values in tables and so on. I want to be able to save the changes I made into
a ew .mdb file so that the name has a reference to when I created it without
me actually having to use the menu and save as. I also want to leave the
original .mdb file in tact,the way it was originally so that I can open it
again and create another .mdb file with a different name and change all the
same tables I changed before.

So my question still remains the same
I have read you can use
FileCopy "C:\test.txt", "C:\test2.txt"

in vb but I dont want the name to be set in vb I want the name to be made by
user interface ie. txt box or listbox If I could set the value for the
test2.txt (using a form)then I can do exactly what I want to do.
 
Top