PDA

View Full Version : نیاز به کد vba برای ساخت db1.mdb روی مسیر a:\



mohkhosh
چهارشنبه 21 تیر 1385, 09:32 صبح
خسته نباشید access کاران عزیز
به یه ماژول یا ماکرو نیاز دارم که با اجراش یه فایل اکسس با نام db1.mdb روی فلاپی ایجاد کنم
لطفا راهنمایی کنید دوستان
متشکر

sarami
چهارشنبه 21 تیر 1385, 10:39 صبح
Dim db As Database
Dim wrkDefault As Workspace
Dim dbsNew As Database
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNew = wrkDefault.CreateDatabase("a:\NewDB.mdb", _
dbLangGeneral, dbEncrypt)

dbsNew.Close

karmand
چهارشنبه 21 تیر 1385, 11:07 صبح
بپیوست ارسال شد کمی در مسیر و نام تیبلها تغیر بده

moustafa
دوشنبه 09 مرداد 1385, 01:03 صبح
ماکرو:
TransferDatabase
در قسمت Transfer type:
export
را انتخاب کن
در اخر کانورت کن به کد ویژوال بیسیک

ramin_xp
سه شنبه 27 آذر 1386, 13:54 عصر
Dim db As Database
Dim wrkDefault As Workspace
Dim dbsNew As Database
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNew = wrkDefault.CreateDatabase("a:\NewDB.mdb", _
dbLangGeneral, dbEncrypt)

dbsNew.Close
سرامی جان همه هیچی اون محل زندگیت منو کشته ...با عرض سلام حالا اگر بخواهیم فرمت ما در درایو مربوط mdb نباشه ومثلا datیاdbf ذخیره بشه چه تغییری در کد میدیم ؟با تشکر همچنین درایو دلخواه رو ما انتخاب کنیم غیر ار دیسکت باشه یعنی

انگوران
سه شنبه 27 آذر 1386, 15:18 عصر
یه همچین کدی رو قبلا" آقا مصطفی برای ساخت یه فایل در یه مسیر دلخواه گذاشته بودن که من با اون خیلی راحتم شاید بدرد شما هم بخوره .

On Error Resume Next
Dim obj As Object
Set obj = CreateObject("Access.Application")
obj.NewCurrentDatabase ("e:\backup.mdb")
MsgBox "ÝÇíá ÓÇÎÊå ÔÏ"

moustafa
سه شنبه 27 آذر 1386, 19:53 عصر
یه همچین کدی رو قبلا" آقا مصطفی برای ساخت یه فایل در یه مسیر دلخواه گذاشته بودن که من با اون خیلی راحتم شاید بدرد شما هم بخوره .

On Error Resume Next
Dim obj As Object
Set obj = CreateObject("Access.Application")
obj.NewCurrentDatabase ("e:\backup.mdb")
MsgBox "ÝÇíá ÓÇÎÊå ÔÏ"
مرسی جیب جان

اگر بخواهیم فرمت ما در درایو مربوط mdb نباشه ومثلا datیاdbf ذخیره بشه چه تغییری در کد میدیم ؟با تشکر همچنین درایو دلخواه رو ما انتخاب کنیم غیر ار دیسکت باشه یعنی
__________________
با copyfile هم میشه هر فایلی رو رو دیسکت یا هر محل دیگه کپی کرد
در رفرنسها هم باید microsot scripting runtimeرا چک بزنید
ومتغیری به شکل زیر تعریف کنید

Dim fso As New FileSystemObject


سینتکس آن از راهنمای اکسس

CopyFile Method


Description

Copies one or more files from one location to another.

Syntax

object.CopyFile source, destination[, overwrite]

The CopyFile method syntax has these parts:

Part Description
object Required. The object is always the name of a FileSystemObject.
source Required. Character string file specification, which can include wildcard characters, for one or more files to be copied.
destination Required. Character string destination where the file or files from source are to be copied. Wildcard characters are not allowed.
overwrite Optional. Boolean value that indicates if existing files are to be overwritten. If True, files are overwritten; if False, they are not. The default is True. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite.



Remarks

Wildcard characters can only be used in the last path component of the source argument. For example, you can use:

FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"

But you can't use:

FileSystemObject.CopyFile "c:\mydocuments\*\R1???97.xls", "c:\tempfolder"

If source contains wildcard characters or destination ends with a path separator (\), it is assumed that destination is an existing folder in which to copy matching files. Otherwise, destination is assumed to be the name of a file to create. In either case, three things can happen when an individual file is copied.

If destination does not exist, source gets copied. This is the usual case.


If destination is an existing file, an error occurs if overwrite is False. Otherwise, an attempt is made to copy source over the existing file.


If destination is a directory, an error occurs.
An error also occurs if a source using wildcard characters doesn't match any files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.