I am stumped over what seens like a simple issue.
I create a new database using the following:
Dim strPath As String
Dim wrkDefault As Workspace
Dim dbsNew As DAO.Database
'capture the path name
strPath = [Export_Path_Entire].Value
'MsgBox "thePath is " & strPath
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
' Make sure there isn't already a file with the name of
' the new database.
If Dir(strPath) <> "" Then Kill strPath
' Create a new database
Set dbsNew = wrkDefault.CreateDatabase(strPath, dbLangGeneral)
Then I create a table, transfer a form and report and copy a form into the new database using the following:
Dim strExportPath As String
If Right(strPath, 4) = ".mdb" Then
strExportPath = strPath
Else
strExportPath = strPath & ".mdb"
End If
'===================================================================================================================
'create the report list in the new database
DoCmd.RunSQL "SELECT Reporting_list_tbl.* INTO Reporting_list_tbl IN '" & strExportPath & "' FROM Reporting_list_tbl;"
'===================================================================================================================
'export the report into the new database
Dim stRptName As String
stRptName = "HIV Status report"
DoCmd.TransferDatabase acExport, "microsoft access", strExportPath, acReport, stRptName, stRptName
'===================================================================================================================
'export the form into the new database
Dim stFrmName As String
stFrmName = "HIV_status_frm"
DoCmd.TransferDatabase acExport, "microsoft access", strExportPath, acForm, stFrmName, stFrmName
'===================================================================================================================
DoCmd.CopyObject strExportPath, , acForm, "menu_report_frm"
Here is the problem...I cannot use any of the events associated with the forms in the new database. I cannot even open the VBA window. When I try to click on a button on either form I get "The expression On Click event that you entered as the event property setting produced the following error: error accessing file. Network connection may have been lost..."
Is there any way to assure that the code associated witrh the forms gets transferred into the new database?
Thanks.
I create a new database using the following:
Dim strPath As String
Dim wrkDefault As Workspace
Dim dbsNew As DAO.Database
'capture the path name
strPath = [Export_Path_Entire].Value
'MsgBox "thePath is " & strPath
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
' Make sure there isn't already a file with the name of
' the new database.
If Dir(strPath) <> "" Then Kill strPath
' Create a new database
Set dbsNew = wrkDefault.CreateDatabase(strPath, dbLangGeneral)
Then I create a table, transfer a form and report and copy a form into the new database using the following:
Dim strExportPath As String
If Right(strPath, 4) = ".mdb" Then
strExportPath = strPath
Else
strExportPath = strPath & ".mdb"
End If
'===================================================================================================================
'create the report list in the new database
DoCmd.RunSQL "SELECT Reporting_list_tbl.* INTO Reporting_list_tbl IN '" & strExportPath & "' FROM Reporting_list_tbl;"
'===================================================================================================================
'export the report into the new database
Dim stRptName As String
stRptName = "HIV Status report"
DoCmd.TransferDatabase acExport, "microsoft access", strExportPath, acReport, stRptName, stRptName
'===================================================================================================================
'export the form into the new database
Dim stFrmName As String
stFrmName = "HIV_status_frm"
DoCmd.TransferDatabase acExport, "microsoft access", strExportPath, acForm, stFrmName, stFrmName
'===================================================================================================================
DoCmd.CopyObject strExportPath, , acForm, "menu_report_frm"
Here is the problem...I cannot use any of the events associated with the forms in the new database. I cannot even open the VBA window. When I try to click on a button on either form I get "The expression On Click event that you entered as the event property setting produced the following error: error accessing file. Network connection may have been lost..."
Is there any way to assure that the code associated witrh the forms gets transferred into the new database?
Thanks.