Create new database and open report!

gMAC

Registered User.
Local time
Today, 02:13
Joined
Dec 21, 2001
Messages
29
I have a large database with over fifty forms for data entry. On each form I have a button for creating a new database to be E-mailed to a customer. This code works great but I would like the newly created database to open with the report opened and maximized. Sample of code.

Private Sub Make Database_Click()
On Error GoTo Err_Make Database_Click

Dim stDocName As String
Dim wsp As Workspace
Dim dbs As Database
Dim strDBFile As String
DoCmd.SetWarnings False

strDBFile = "C:\Folder To Hold Databases\New Name " & Me.JobID & ".mdb"

Set wsp = DBEngine.Workspaces(0)
Set dbs = wsp.CreateDatabase(strDBFile, dbLangGeneral)
dbs.close
Set dbs = Nothing
Set wsp = Nothing

stDocName = "QryMakeNewTable"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.CopyObject strDBFile, , acTable, "_MyNewTable"
DoCmd.CopyObject strDBFile, , acReport, "_MyReport"

MsgBox "Database Has Been Created!"
Exit_Make Database_Click:

DoCmd.SetWarnings True
Exit Sub

Err_Make Database_Click:
MsgBox Err.Description
Resume Exit_Make Database_Click

End Sub

Being I will have to do this for each form, is there a simple way to attach code to open the reports on database open?

Thanks
gMAC
 

Users who are viewing this thread

Back
Top Bottom