I am an experienced VB6 programmer but a novice when it comes to MS Access. I have a form for ECO's (Engineering Change Orders) based on the table ECO, and in it I created a subform that is linked to a table called Attachments. The attachments are files related to the ECO. I used the wizard to do the work of adding the subform. So far, so good. As I cycle through the ECO's, the subform populates with the file attachments.
What I need to do is to be able to add new attachments or delete existing ones. I can delete existing ones by simply selecting the row in the attachments subform and hitting Delete, although this seems a little dangerous. What is the easiest way to add a new attachment? By the way, my attachment table includes the file title and a hyperlink that includes the full path name and file title. I have code to locate another file, as shown below. It's what I do next that has me wondering.
Expand|Select|Wrap|Line Numbers
- Dim objCMDlg As Object
- Dim strFileName As String
- Dim strHelpFile As String
- Dim strMethod As String
- Dim FileTitle As String
- Dim FilePathName As String
- Dim sAttachment As String
- On Error GoTo HandleErr
- strMethod = "SHOWOPEN"
- Set objCMDlg = Forms![ECOForm].ComDialogAttachment
- objCMDlg.CancelError = True
- With objCMDlg
- Select Case UCase(strMethod)
- Case "SHOWOPEN"
- ' File Open dialog box
- .Filename = "*.*"
- .InitDir = "\\network location"
- .Filter = "All File(*.*)|*.*"
- .ShowOpen
- If Len(.Filename) <> 0 Then
- FileTitle = .FileTitle
- FilePathName = .Filename
- sHyperlink = "#" & FilePathName & "#"
- End If
- End Select
- End With