Code: Between [Start Date] And [End Date] on the query.I want to reference a form, which i figured would be like this
Code: Between [Forms]![frmSBReports]![txtStartDate] And [Forms]![frmSBReports]![txtEndDate]But this doesnt work! What did I do wrong here? Any help as always is greatly appreciated!
Code: Private Sub Command65_Click() Dim MyFilter As String If Me.Filter = "" Then MsgBox "Please apply a filter to the form first." ElseIf Me.Dirty Then ' Make sure the record is saved RunCommand acCmdSaveRecord Else MyFilter = Me.Filter DoCmd.OpenReport "Temp", acViewPreview, , MyFilter End If End SubHow to I change this so that it now stores the value in the Public variable instead of the Private one which it is doing above?
Code: [weeklyCaseSales]=[forms]![frmRetailerQuery]![txtWeeklyCaseSales] Or [forms]![frmRetailerQuery]![txtWeeklyCaseSales] Is NullThis is great for searching for single values, e.g. "weeklyCaseSales = 10", but the user also wants to search for ranges, e.g. "weeklyCaseSales > 5 and weekly Case Sales < 20". This means I will need two text boxes on the form e.g. txtMinCaseSales and txtMaxCaseSales. But how do I then use these in the query def (and also allow for the fact that one or both of them could be Null ?).
Code: Between ([Forms]![frm_Data]![text101] Or Like [Forms]![frm_Data]![text101] & "*") and ([Forms]![frm_Data]![text102] Or Like [Forms]![frm_Data]![text102] & "*")However, Access modified my code to this
Code: Between (([tbl_Data].[Start])=[Forms]![frm_Data]![text101] Or ([tbl_Data].[Start]) Like [Forms]![frm_Data]![text101] & "*") And (([tbl_Data].[Start])=[Forms]![frm_Data]![text102] Or ([tbl_Data].[Start]) Like [Forms]![frm_Data]![text102] & "*")And it does not work. Any suggestions on how to do this?
Code: Between Forms!frmSwictboard!frmDatabaseReports!txtStartDate and Forms!frmSwictboard!frmDatabaseReports!txtEndDateI cannot for the life of me pass through this parameter using QueryDef.
Code: Dim qdf As QueryDef Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb Set qdf = db.QueryDefs("qryrptAllOverdueIncidents") qdf.Parameters("IncDateRaised") = "Between Forms!frmSwictboard!frmDatabaseReports!txtStartDate And Forms!frmSwictboard!frmDatabaseReports!txtEndDate" Set rs = qdf.OpenRecordset 'Start a new workbook in Excel Dim oApp As New Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet Set oBook = oApp.Workbooks.Add Set oSheet = oBook.Worksheets(1) 'Add the field names in row 1 Dim i As Integer Dim iNumCols As Integer iNumCols = rs.Fields.Count For i = 1 To iNumCols oSheet.Cells(1, i).Value = rs.Fields(i - 1).name Next 'Add the data starting at cell A2 oSheet.Range("A2").CopyFromRecordset rs 'Format the header row as bold and autofit the columns With oSheet.Range("a1").Resize(1, iNumCols) .Font.Bold = True .EntireColumn.AutoFit End With oApp.Visible = True oApp.UserControl = True 'Close the Database and Recordset rs.Close db.CloseIs it even possible to pass through a parameter like this using querydef?
Code: between [forms]![mainform]![begindate_from) AND [forms]![mainform]![begindate_to]field: enddate
Code: Isnull([enddate] OR between [forms]![mainform]![enddate_from) AND [forms]![mainform]![enddate_to]The part IsNull([enddate]) is of course not used, because in my form the two fields (enddate from and enddate to) are always filled...