My database is used to manage 400+ projects. It uses a number of linked tables and queries. I need to import a spreadsheet containing information that will be attached to several different tables. My problem is in associating the imported spreadsheet to an individual project when it is imported.
I have used importspreadsheet code that I have sourced here and it works fine. But the association part has me stumped. Can anybody offer any suggestions? Thank you in advance for any help.
A unique project is selected from a list on a form with this code:
Private Sub button_view_edit_Click()
On Error GoTo Err_button_view_edit_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "f02_application_detail"
If Not IsNull([application_id]) Then
stLinkCriteria = "[application_id]=" & Me![application_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_button_view_edit_Click:
Exit Sub
Err_button_view_edit_Click:
MsgBox Err.Description
Resume Exit_button_view_edit_Click
End Sub
Here is my importspreadsheet code (which is a work in progress - the queries do not exist in my database, and I am writing them as I go):
Private Sub cmdImportOPR_Click()
Dim strPath As String 'Filepath and name
DoCmd.SetWarnings False
path = strPath
filename = strPath
'append application_id
"[f30]=" & Me![application_id]
DoCmd.OpenQuery "q80_append_application_id_to_opr_temp"
'import the Operational Phase Report
DoCmd.TransferSpreadsheet acImport, , "tbl_opr_temp", Me!txtFilePath, False, "a1:z600"
'move the data from the temporary table to the appropriate tables
DoCmd.OpenQuery "QRY_ImpCln"
'clear the temporary table ready for the next operational phase report
DoCmd.OpenQuery "QRY_ClrTBL_Import"
DoCmd.Close acForm, "FRM_Import"
Forms!frm_welcome!Update = Date
Forms!frm_welcome.Requery
MsgBox "Grego you're awesome"
Forms!frm_welcome.Text6.SetFocus
DoCmd.SetWarnings True
End Sub
I have used importspreadsheet code that I have sourced here and it works fine. But the association part has me stumped. Can anybody offer any suggestions? Thank you in advance for any help.
A unique project is selected from a list on a form with this code:
Private Sub button_view_edit_Click()
On Error GoTo Err_button_view_edit_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "f02_application_detail"
If Not IsNull([application_id]) Then
stLinkCriteria = "[application_id]=" & Me![application_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_button_view_edit_Click:
Exit Sub
Err_button_view_edit_Click:
MsgBox Err.Description
Resume Exit_button_view_edit_Click
End Sub
Here is my importspreadsheet code (which is a work in progress - the queries do not exist in my database, and I am writing them as I go):
Private Sub cmdImportOPR_Click()
Dim strPath As String 'Filepath and name
DoCmd.SetWarnings False
path = strPath
filename = strPath
'append application_id
"[f30]=" & Me![application_id]
DoCmd.OpenQuery "q80_append_application_id_to_opr_temp"
'import the Operational Phase Report
DoCmd.TransferSpreadsheet acImport, , "tbl_opr_temp", Me!txtFilePath, False, "a1:z600"
'move the data from the temporary table to the appropriate tables
DoCmd.OpenQuery "QRY_ImpCln"
'clear the temporary table ready for the next operational phase report
DoCmd.OpenQuery "QRY_ClrTBL_Import"
DoCmd.Close acForm, "FRM_Import"
Forms!frm_welcome!Update = Date
Forms!frm_welcome.Requery
MsgBox "Grego you're awesome"
Forms!frm_welcome.Text6.SetFocus
DoCmd.SetWarnings True
End Sub