Hello good people! 
So I'm in the middle of this Access project where I'm changing every form to connect directly to a MySQL server instead of using local tables. I have been able to change everything correctly up to now. In one of my forms a use a botton to pass everything that has been filtered by the user to a new Excel file. That worked great with local tables with this code:
But now since the RecordSource is empty because I'm connecting directly to MySQL tables its not working so I tried this:
No luck there! :banghead:
I use this on load form to connect to the database and pull the records needed for the form and everything loads fine and I'm even able to filter the form:
I literally have no more ideas on how to approach this. All help is appreciated 

So I'm in the middle of this Access project where I'm changing every form to connect directly to a MySQL server instead of using local tables. I have been able to change everything correctly up to now. In one of my forms a use a botton to pass everything that has been filtered by the user to a new Excel file. That worked great with local tables with this code:
Code:
Private Sub Command27_Click()
'Error Handler
On Error GoTo errHandler
Dim qdf As QueryDef
DoCmd.DeleteObject acQuery, "qryTemp"
Set qdf = CurrentDb.CreateQueryDef("qryTemp", Me.Child13.Form.RecordSource)
DoCmd.OutputTo acOutputQuery, "qryTemp", acFormatXLS, , True
Exit Sub
'Error Handler
errHandler:
MsgBox "Error."
exitHandler:
End Sub
Code:
Private Sub Command28_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim SQL As String
Set db = OpenDatabase("", False, False, Globales.ConnString)
SQL = "SELECT tbl1Facturas.Verificado, tbl1Facturas.Factura, tbl1Facturas.Fecha, tbl5Localidades.NombreLocalidad, tbl6Suplidores.NombreSuplidor, tbl1Facturas.Subtotal, tbl1Facturas.[IVU MUNICIPAL], tbl1Facturas.[IVU ESTATAL], tbl1Facturas.[Total de Compra], tbl1Facturas.[Exento al IVU ESTATAL], tbl1Facturas.[Credito al Subtotal], tbl1Facturas.[Credito IVU Municipal], tbl1Facturas.[Credito IVU ESTATAL], tbl1Facturas.[Metodo de Pago], tbl1Facturas.[ID Metodo Pago], tbl1Facturas.MetodoPago_PDF, tbl1Facturas.Factura_PDF " _
& "FROM (tbl1Facturas INNER JOIN tbl5Localidades ON tbl1Facturas.Localidad_ID = tbl5Localidades.ID) INNER JOIN tbl6Suplidores ON tbl1Facturas.Suplidor_ID = tbl6Suplidores.ID " _
& "WHERE MONTH(tbl1Facturas.Fecha) = Month(#" & Me.Text19 & "#) " _
& "AND YEAR(tbl1Facturas.Fecha) = Year(#" & Me.Text19 & "#) " _
& "AND tbl1Facturas.Localidad_ID = " & Me.Combo23.Column(0) & " " _
& "ORDER BY tbl1Facturas.Fecha; "
Set qdf = db.CreateQueryDef("qryTemp", SQL)
DoCmd.OutputTo acOutputQuery, "qryTemp", acFormatXLS, , True
Exit Sub
End Sub
I use this on load form to connect to the database and pull the records needed for the form and everything loads fine and I'm even able to filter the form:
Code:
Private Sub fillSubForm()
'Set Form Recordset
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim SQL As String
Set db = OpenDatabase("", False, False, Globales.ConnString)
SQL = "SELECT tbl1Facturas.Verificado, tbl1Facturas.Factura, tbl1Facturas.Fecha, tbl5Localidades.NombreLocalidad, tbl6Suplidores.NombreSuplidor, tbl1Facturas.Subtotal, tbl1Facturas.[IVU MUNICIPAL], tbl1Facturas.[IVU ESTATAL], tbl1Facturas.[Total de Compra], tbl1Facturas.[Exento al IVU ESTATAL], tbl1Facturas.[Credito al Subtotal], tbl1Facturas.[Credito IVU Municipal], tbl1Facturas.[Credito IVU ESTATAL], tbl1Facturas.[Metodo de Pago], tbl1Facturas.[ID Metodo Pago], tbl1Facturas.MetodoPago_PDF, tbl1Facturas.Factura_PDF " _
& "FROM (tbl1Facturas INNER JOIN tbl5Localidades ON tbl1Facturas.Localidad_ID = tbl5Localidades.ID) INNER JOIN tbl6Suplidores ON tbl1Facturas.Suplidor_ID = tbl6Suplidores.ID " _
& "ORDER BY tbl1Facturas.Fecha;"
Set rs = db.OpenRecordset(SQL, dbOpenDynaset, dbPessimistic)
Set Me.Child13.Form.Recordset = rs
