ChrisHannah
Registered User.
- Local time
- Today, 17:33
- Joined
- Dec 15, 2016
- Messages
- 12
Hello
I need to set up an event and have people upload a list of attendees each time they fill out my form for this event, they will fill out a form and then select a button to import a spreadsheet.
I need to have the primary key associated with the event that i am creating be assigned to each entry that i have imported i make into a new table.
I have a form and button that imports a spreadsheet to a table "StagingTable"
this works fine but i cannot figure out how to assign the primary key to the entries. (i have set up relationships).
my button code is below:
I need to set up an event and have people upload a list of attendees each time they fill out my form for this event, they will fill out a form and then select a button to import a spreadsheet.
I need to have the primary key associated with the event that i am creating be assigned to each entry that i have imported i make into a new table.
I have a form and button that imports a spreadsheet to a table "StagingTable"
this works fine but i cannot figure out how to assign the primary key to the entries. (i have set up relationships).
my button code is below:
Code:
Private Sub Command364_Click()
' This requires a reference to the Microsoft Office 11.0 Object Library.
Dim fDialog As FileDialog
Dim varFile As Variant
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Select Your Excel File"
' Clear out the current filters, and then add your own.
.Filters.Clear
.Filters.Add "Excel Files", "*.xls;*.xlsx"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
Me.txtFilePath = varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "YourSTAGINGTable", Me.txtFilePath, True
End Sub