Im trying to on button export a subform but all I am getting it various errors mostly It cant seem to recognize the subform object. The closest I am I think is the following :
DoCmd.OutputTo acOutputForm, Me.Form.<Subform_name>.Name, acFormatXLSX, savefileas, True
subform_name is the object name in the main form Subform_form the source form
the sub form doesn't come from a separate query but record set is set from VBA of the parent form
The error on this vba is 2102 = "the form name is misspelled or refers to a form that doesn't exist."
savefileas =
Public Function savefileas() As String
Dim fd As FileDialog, filename As String
On Error GoTo ErrorHandler
Set fd = Application.FileDialog(msoFileDialogSaveAs)
If fd.Show = True Then
If fd.SelectedItems(1) <> vbNullString Then
filename = fd.SelectedItems(1)
End If
Else
'Stop Code Execution for Null File String
End
End If
savefileas = filename & ".xlsx"
'Cleanup
Set fd = Nothing
Exit Function
ErrorHandler:
Set fd = Nothing
MsgBox "Error " & Err & ": " & Error(Err)
End Function
Me.<Subform_name>.SourceObject
instaed ofMe.Form.<Subform_name>.Name
– Sergey S.