megan5marie
New member
- Local time
- Today, 12:31
- Joined
- Apr 25, 2024
- Messages
- 7
Hello and thank you in advance for any help you can give me.
I was recently converted to Office 365, and as a result, DoCmd.TransferSpreadsheet no longer trims trailing spaces from field names.
I have a database that imports a single file from a client. (Please see form code below.) The filenames are never the same, so I don't believe linking instead of importing is an option.
There is one field name in the client files that sometimes has a trailing space and sometimes doesn't. (Asking the client to keep this consistent is not an option.) Until conversion to Office 365, this was not an issue; the trailing space were trimmed automatically upon import. Is there any way to have trailing spaces in field names trimmed upon DoCmd.TransferSpreadsheet with Office 365?
Thank you.
I was recently converted to Office 365, and as a result, DoCmd.TransferSpreadsheet no longer trims trailing spaces from field names.
I have a database that imports a single file from a client. (Please see form code below.) The filenames are never the same, so I don't believe linking instead of importing is an option.
There is one field name in the client files that sometimes has a trailing space and sometimes doesn't. (Asking the client to keep this consistent is not an option.) Until conversion to Office 365, this was not an issue; the trailing space were trimmed automatically upon import. Is there any way to have trailing spaces in field names trimmed upon DoCmd.TransferSpreadsheet with Office 365?
Thank you.
Code:
Private Sub btn_ImportDataFile_Click()
Dim Response As Integer
Dim fd As FileDialog
Dim fileName As String
Response = MsgBox("This will import a data file into the system. Do you wish to proceed?", vbYesNo, "Import Data File")
If Response = vbYes Then
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = False
fd.Filters.Clear
fd.Filters.Add "Client Data File", "*.xlsx"
fd.Filters.Add "Client Data File", "*.xls"
If fd.Show = True Then
If fd.SelectedItems(1) <> vbNullString Then
fileName = fd.SelectedItems(1)
End If
End If
If fileName <> vbNullString Then
DoCmd.SetWarnings (WarningsOff)
DoCmd.TransferSpreadsheet transferType:=acImport, TableName:="DataFile", fileName:=fileName, hasfieldnames:=True
Response = MsgBox("Data has been imported.", vbOKOnly, "Import Data File")
End If
End If
End Sub