I a trying to search some product from a search button and two combo boxes text values ,and on serch the vba code is :
and the query(qryPrintBrand) code is
I just dont know,the fuile is created on click of button but with headers only,dtaa is not coming but wheni debug ,in immediate window,data is oming but just not coming in excel file !.
need help with this
Thanks
Code:
Private Sub Command4_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim varRecords As Variant
Dim intNumReturned As Integer
Dim intNumColumns As Integer
Dim intColumn As Integer
Dim intRow As Integer
Dim strParam As Integer
Dim strParam1 As Integer
Dim Myqdf As DAO.QueryDef
Dim ctl As String
If IsNull(Me!Combo13) Then
MsgBox "Please Choose a Name from the drop down box above"
Exit Sub
End If
ct1 = Forms!frmSearchByBrandName.Combo13.Column(1)
ct2 = Forms!frmSearchByBrandName.Combo15.Column(1)
Set db = CurrentDb()
Set Myqdf = db.QueryDefs("qryPrintBrand")
Myqdf.Parameters("Forms!frmSearchByBrandName!Combo13") = ct1
Myqdf.Parameters("Forms!frmSearchByBrandName!Combo15") = ct2
Set rs = Myqdf.OpenRecordset()
varRecords = rs.GetRows(1000)
intNumReturned = UBound(varRecords, 2) + 1
intNumColumns = UBound(varRecords, 1) + 1
For intRow = 0 To intNumReturned - 1
For intColumn = 0 To intNumColumns - 1
Debug.Print varRecords(intColumn, intRow)
Next intColumn
Next intRow
'FileLocation = "C:\Users\hahmed\Desktop\navigation\New folder"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryPrintBrand", "C:\Users\hahmed\Desktop\navigation\New folder\test.xls", True
MsgBox "File Created!" & vbCrLf & vbCrLf & "File location: " & FileLocation
End Sub
and the query(qryPrintBrand) code is
Code:
SELECT tblCustomers.CustomerDesc, tblProductInfo.ProductNumber, tblProductInfo.ProductDesc1, tblProductInfo.ProductDesc2, tblBrand.BrandDesc, tblBrand.CustomerID, tblProductInfo.UPCCode, tblProductInfo.Effective, tblProductInfo.DateUsed, tblProductInfo.FilmCoding, tblProductInfo.RetailCoding, tblProductInfo.ProductInfoLocation, tblProductInfo.LabelImage, *
FROM (tblCustomers LEFT JOIN tblBrand ON tblCustomers.CustomerID = tblBrand.CustomerID) LEFT JOIN tblProductInfo ON tblCustomers.CustomerID = tblProductInfo.Customer
WHERE tblCustomers.CustomerDesc= forms!frmSearchByBrandName!Combo13 AND tblBrand.BrandDesc=forms!frmSearchByBrandName!Combo15;
I just dont know,the fuile is created on click of button but with headers only,dtaa is not coming but wheni debug ,in immediate window,data is oming but just not coming in excel file !.
need help with this
Thanks