I am running a query which returns daily sales numbers a also calculates a percentage increase. The query works fine until I try entering criteria to give any percentages that are >150 or <50, when running this no results are returned. Any help on this would be greatly appreciated.
ChildName: [tblChildren_LName] & ", " & [tblChildren_FName] (also, in the tblMain I have employeeNum, LName, FName.... )hence drawing the names from the tblChildren..
I have it in a query, I am just trying to make the last and first name a field for a report. But when I run the query I am asked: enter Parameter value tblChidren_LName and tblChildren_FName.
In the query I have two tables
tblMain and tblChildren. EntryNumber is the PK.
The same expression works in an another query that I have...but for some reason it is not working in this one...
Hi all, I wonder if anyone can help me? What I am trying to do is relativley simple but I am just having a problem executing the expression.
I have a search form which returns the list of results in a subform, in the search form (attached), there is a field which is to bring back results for contracts due in X amount of days, where the user inputs X. In the query results I only want this field to queried on if something is actually typed into the field. The field in the query I am writing this under is called [RenDate]. I have written a criteria expression in my query as follows, but am getting no results:
IIf(IsNull([Forms]![F Search]![days for renewal]),"",[RenDate] Between Date() And Date()+[Forms]![F Search]![days for renewal])
Everything else is working fine with this form/query. If anyone could help or advise on my expression it would be much appreciated.
I'm a little new to Access but I'm trying to create an IIf Expression:
iif ( condition, value_if_true, value_if_false )
Mine is: Au_ppb: IIf([Element]="Au" And [Units]="ppb",[Result],Null)
I need to have three criteria's (each looking into a different column). I can get two criterias but not three:
[Element]="Au" And [Units]="ppb"
When I add in the third (And [Priority]="12") it doesn't work .
Also, I need to have about 6 columns with similar IIF statements in the one query in my query and if a row has Null for all then I don't want it visible however if I make the Criteria "Is not Null" on one column or on all it comes up with no results.
I have a grades_table with data regarding a grade a person gets. It contains like Name, Date, Grade, Grader_Name, Month, Year...
I have another table (grader_table) that contains the Grader_Name, and how many Grades that grader needs done in a given month (i'm using two numbers to indicate month and year).
What I would like to do is I have a form where all info for the grades_table is entered. When the query is run, I would like to have the month and Year field use the date given to auto fill numbers.
So I picture it as like 6/5/07 is given, so the query records the date, but also stores the 5 and 7 in other columns. I tried this in my query for i think its title - Month: Month([Date]) but it says there one too many ")".
I have a feeling I may also need help with the actual retrieval of a months score since it will cross tables, but this is the big question for now. Any help is appreciated.
I have a query I'm working with that finds data that changes, calculates the numbers, then prints a result in another column. The problem is that if I don't have any changes, then I have a blank result. Normally this wouldn't be a problem, but I'm making reports available to other users and would like this populated.
What seems simplest is to add an expression in the criteria field for the column that displays data after crunching numbers. Since this only has a display if something has changed, then I need an expression added if there is no data. Can I add something like an IsNull expression to display the results from another column in the same table? The data will end up being redundant, but I'm ok with that for now. the report should probably have the expression, but the column is already here in this table.
can someone tell me why I getting this error when I try and run this query:
select distinct case_id from NOLDBA_RPT_CASE_CHG_IND G
where sys_curr_date between '01/01/2005' and '12/31/2005' and aft_case_status = 'O'
and not exists ( select 1 from NOLDBA_RPT_CASE_CHG_IND X where X.case_id = G.case_id and X.aft_case_status = 'C' and X.sys_curr_date = G.sys_curr_date )
My query is coming along nicely, but as always once one problem is solved you find another :rolleyes: !
My problem is that I have thus far specified criteria for the field OrdDeliveryCountry, but this field is not filled in unless the delivery address is different from the default address for the customer, therefore it is frequently blank and so the query wasn't finding all records, only those where the Delivery Address was specific to the order.
I want to use the IIf function to make an expression to say (in linguistic terms): If OrdDeliveryCountry is blank, then use the country in the Customers table.
Sounds simple enough, but the criteria currently is: WHERE (((ORDERS.ORDDELIVERYCOUNTRY) = "Austria" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Belgium" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Cyprus" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Czech Republic" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Denmark" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Estonia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Finland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "France" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Germany" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Greece" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Hungary" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Ireland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Italy" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Latvia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Lithuania" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Luxembourg" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Malta" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Holland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Poland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Portugal" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovakia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovenia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Spain" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Sweden") AND ((PRODUCTS.PRODUCTNAME) NOT LIKE "*Upgrade" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Repair" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Rpr" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Commission") AND ((ORDERS.[DEMO/SALEID]) = 2))
So how do I combine the IIf(expr,truepart,falsepart) with "Is Not x Or x Or x"?I.E. I need to get it to exclude records where OrdDeliveryCountry does not equal one in the list, and if that is blank then the Country field in the Customers table does not equal one in the list?
My attempt is this, but I think I'm way off the mark
SELECT ORDERS.SHIPDATE, PRODUCTS.[STANDARD TARRIFF NUMBER], [ORDER DETAILS].[QUANTITY] * [ORDER DETAILS].[UNITPRICE] * (1 - [DISCOUNT]) * (1 - [SPECIAL DISCOUNT]) AS LINETOTAL, [ORDER DETAILS].QUANTITY, ORDERS.ORDDELIVERYCOUNTRY, ORDERS.ORDERID, [ORDER DETAILS].PRODUCTID FROM CUSTOMERS RIGHT JOIN (PRODUCTS RIGHT JOIN (ORDERS LEFT JOIN [ORDER DETAILS] ON ORDERS.ORDERID = [ORDER DETAILS].ORDERID) ON PRODUCTS.PRODUCTID = [ORDER DETAILS].PRODUCTID) ON CUSTOMERS.CUSTOMERID = ORDERS.CUSTOMERID WHERE (((ORDERS.ORDDELIVERYCOUNTRY) = IIF(ISNULL([ORDERS]![ORDDELIVERYCOUNTRY]),([CUSTOMERS]![COUNTRY] NOT LIKE "Austria" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Belgium" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Cyprus" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Czech Republic" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Denmark" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Estonia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Finland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "France" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Germany" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Greece" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Hungary" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Ireland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Italy" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Latvia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Lithuania" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Luxembourg" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Malta" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Holland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Poland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Portugal" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovakia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovenia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Spain" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Sweden"), (([ORDERS]![ORDDELIVERYCOUNTRY]) NOT LIKE "Austria" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Belgium" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Cyprus" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Czech Republic" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Denmark" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Estonia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Finland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "France" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Germany" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Greece" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Hungary" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Ireland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Italy" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Latvia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Lithuania" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Luxembourg" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Malta" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Holland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Poland" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Portugal" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovakia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Slovenia" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Spain" OR (ORDERS.ORDDELIVERYCOUNTRY) = "Sweden"))) AND ((PRODUCTS.PRODUCTNAME) NOT LIKE "*Upgrade" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Repair" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Rpr" AND (PRODUCTS.PRODUCTNAME) NOT LIKE "*Commission") AND ((ORDERS.[DEMO/SALEID]) = 2)) ORDER BY ORDERS.SHIPDATE DESC;
My thoughts:
Maybe I need to re-structure the WHERE clause? Would it work if the IIf expresssion was in the SELECT part not the WHERE part?
I would really appreciate some help with this: I'm not sufficiently familiar with structuring statements as complex as this and I don't know all the syntax rules etc.
I need to be able to add x months to a given date which I'm using in a criteria expression. I've figured out that I can just add y number of days, but the answers aren't quite accurate across different ranges of months.
I'm after something like <[BeginDate] And >([BeginDate]+[3months])
but I haven't turned up anything useful in an hour of googling - finding it difficult to define what I want in search engine terms.
I would be much obliged if someone would help me here.
I have the following code which takes a value from a combobox and uses it in an sql statment to find a certain record and then it populates the GUI with that recordset , however I get the following error "Data type mismatch in criteria expression"
Please help
CODE:
Private Sub cmdSearch_Click()
Dim sql As String Dim rsUpdate As New ADODB.Recordset
On Error GoTo DbError
sql = "SELECT * FROM ServiceReport WHERE CallReferenceNo= " & Me.cboSearchRef.Value
hi guys, here is my problem.the error in the title appears when i try to update a record.the field MODON in the table is defined as a short date and an input date 00/00/0000.Here is the code where i insert and update the records: Option Compare DatabaseOption ExplicitPrivate Sub Command4_Click()On Error GoTo Err_Command4_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmCalendar" DoCmd.OpenForm "frmCalendar", , , , , acDialog, Me.name & ";modon"Exit_Command4_Click: Exit SubErr_Command4_Click: MsgBox Err.description Resume Exit_Command4_Click End SubPrivate Sub Command15_Click()Dim str1 As DateOn Error GoTo Err_Command15_Click 'DoCmd.SetWarnings False If DCount("[comment]", "comments", "[change_id]=" & Me.Task_Num & "") = 0 Then MsgBox "insert" DoCmd.RunSQL "insert into [comments] (change_id,modon,comment,modby,modif) values (" & Me.Task_Num.Value & ",'" & Me.modon.Value & "','" & Me.Text10.Value & "','" & Forms!Login!username1 & "','" & Now() & "');" DoCmd.SetWarnings True Else MsgBox "update" MsgBox DLookup("[comment]", "comments", "[modon]='" & CStr(Me.modon.Value) & "'") DoCmd.RunSQL "update [comments] set comment='" & Me.Text10.Value & "' where change_id=" & Me.Task_Num & " and [modon]='" & Format(str1, "dd/mm/yyyy") & "';" DoCmd.RunSQL "update [comments] set modby='" & Forms!Login!username1 & "' where change_id=" & Me.Task_Num & " and [modon]='" & Me.modon.Value & "';" DoCmd.RunSQL "update [comments] set modif='" & Now() & "' where change_id=" & Me.Task_Num & " and [modon]='" & Me.modon.Value & "';" End If DoCmd.SetWarnings True Exit_Command15_Click: Exit SubErr_Command15_Click: MsgBox Err.description Resume Exit_Command15_Click End SubPrivate Sub Command16_Click()On Error GoTo Err_Command16_Click DoCmd.CloseExit_Command16_Click: Exit SubErr_Command16_Click: MsgBox Err.description Resume Exit_Command16_Click End SubPrivate Sub Command4_Exit(Cancel As Integer) If IsEmpty(Me.modon) Then MsgBox "Please, select a date for the minute" Me.modon.SetFocus Else Me.Task_Num.Visible = True End IfEnd SubPrivate Sub Form_Load() Me.Text13.Visible = False Me.Text10.Visible = False Me.Label12.Visible = False Me.Label9.Visible = False Me.Task_Num.Visible = FalseEnd SubPrivate Sub task_num_AfterUpdate() If IsEmpty(Me.Task_Num) Then MsgBox "Please, select a task Number" Me.Task_Num.SetFocus Else Me.Text13.Visible = True Me.Text10.Visible = True Me.Label12.Visible = True Me.Label9.Visible = True Me.Text13 = DLookup("[description]", "newchange", "[change_id]=" & Me.Task_Num & "") Me.text10 = DLookup("[comment]", "comments", "[change_id]=" & Task_Num & " and [modon]='" & Me.modon.value & "'") End IfEnd Subthx in advance....
I am trying to set a recordset, and I keep getting this data type mismatch error, but I cannot see what the problem is. Here's my code:
Set rstAccounts = dtbCurrent.CreateQueryDef("", "SELECT [Account ID], [Balance] FROM tblAccounts WHERE [Account ID]='" & txtAccountID.Value & "';").OpenRecordset
txt.AccountID.Value is 1, and when I hard code the value as 1 it works, so I'm not sure what the problem is. I've tried using CStr() to convert it to a string, CInt() to convert it to a integer (even though it already is one), with using both quotes, with only double quotes, and with only single quotes. It's driving me crazy, because i'm sure it's something really simple, but I'm not sure what else to try.
I've never used DLookup before and I can't get it to work for me so far.
I have 1 table which contains products and different properties of each product, such as the weight of the product.
I have created a query which sums the weight of all products, but only for those that have a value >0 in a certain field. This all works fine.
Now I simply want to display that calculated total weight in a text box on a form. So I thought DLookup could be used for that. But I can't get it to work, maybe because I'm not putting in any criteria? In the control source of the text box I've put the following:
=dlookup("[TotalWeight]","qryTotals")
I don't have any criteria, I just want the value from my qry expression. The textbox on my form now displays #name?
How to write an expression/criteria in a query that will return only ID numbers with alpha numeric values. Example: My Id field contains both numeric 479621, 680530 and alpha numeric 132NAV100, 174NAV26a values. I want to run the query to return only the alpha numeric values.
I have a query that uses two criteria from a user input form. On the form, the user would input a customers last name and use a dropdown list (based on a table 30,60,90,120,365 days) to select how many days previous they want to search. Unfortunately there is something that I'm over looking and can't figure out.
Let's say I have multiple records that match the following criteria: Last name "James", days since contracted all less than 30 days. For some reason when I put in "James" as the last name in my form and select "30" from the droplist, it only lists the most current one which is zero days. Even if I select "60" from the droplist, it still only shows the zero day contract.
If I go back and select "90" from the droplist is brings up 3 - 3 day old contracts and my 1 zero day old contract. If I select 120, it picks up another contract that is 4 days old. If I select 365 it picks up a couple more, but still not everything. Here is my SQL code.
Code: SELECT tblAllData.[F&I Manager], tblAllData.[Reviewing BOA], tblAllData.Date, tblAllData.[Stock#], tblAllData.[Deal Date], tblAllData.[Cust First Name], tblAllData.[Cust Last Name], Round(DateDiff("d",[deal date],Now()))/1 AS Days, tblAllData.[Bank Name],
The error I'm getting is "data type mismatch in criteria expression".
Private Sub BtnAddBooking_Click() Dim CustomerID As String Dim StaffID As String Dim intPos As Integer Dim strSQL As String Dim strSQL2 As String Dim BathValue As Integer Dim rst As DAO.Recordset Dim RemainingBookingExists As String Dim RemainingBaths As Integer Dim RemainingBathsExists As String
I am trying to count the amount of records that were created and closed for last month but I am having problems inserting the correct criteria along with the DCOUNT syntax. DCount("*","obsvnofilterqry","(Date_Closed)=MONTH( Date())").Works fine but figuring out how to get the amount of Date_Closed for last month is proving tricky.
I'm trying to create an query that has two separate expression in it and a date selection criteria. The first expression is,
Expr1: DateDiff("s", [Arrival Time 1],[Departure Time 1])/3600
and the second is,
Expr2: IIf([Expr1]>[Hours Per Day],[Expr1]-[Hours Per Day]
When I run this query it asks me for the date (which is fine) but then it also pops up a box asking for "Expr1". How can I get "Expr2" to use the value returned from "Expr1"?
Code: SELECT prevwd([practice_bacs_submission_date])<Date() AS chase_it, practice_bacs.practice_bacs_submission_date FROM practice_bacs WHERE (((practice_bacs.practice_bacs_submission_date)>#1/31/2013#));
and in the query results I see 0 and -1 as expected for the 'chase_it' expression BUT When I add True (or -1, or 0) as a criteria for 'chase_it', I get the "Data type mismatch in criteria expression" error.So the sql that fails is
Code: SELECT prevwd([practice_bacs_submission_date])<Date() AS chase_it, practice_bacs.practice_bacs_submission_date FROM practice_bacs WHERE (((prevwd([practice_bacs_submission_date])<Date())=True) AND ((practice_bacs.practice_bacs_submission_date)>#1/31/2013#));
In case it's relevant, my function prevwd is:
Code: Function prevwd(dt As Date) As Date 10 On Error GoTo prevwd_Error 20 dt = dt - 1 30 While Weekday([dt]) = 1 Or Weekday([dt]) = 7 Or IsBankHoliday(dt)
[code]...
and this function is used extensively and always works perfectly. I have tried using DateAdd instead of dt = dt - 1, but that made no difference.
I am creating a simple query in a farm audit database.
In criteria of the customers field, i have entered "Farmer One" as this is the customers data which I want to retrieve and in the Totals section I have changed the setting to Where instead of group by, but I am still getting "Data type mismatch in criteria expression" popping up.why this is?
I am trying to insert a text box value into a text field value in a table. I am checking to see if the value is already in the table but come across an error on the second click. The first click enters the number, and the second click gets error. I know where the error is but I'm not sure why or how to fix it.
Code:Dim db As DAO.DatabaseDim rs As DAO.RecordsetSet db = CurrentDb()Set rs = CurrentDb.OpenRecordset("CVHOLD", dbOpenDynaset)If Not rs.BOF Then rs.MoveFirstrs.FindFirst "[Batch Number] = " & Me![Batch Number]'Error here on second passIf (rs.EOF) Then 'Seems to insert new record properly 'No Batch Number in Table yet. rs.AddNew rs("Batch Number") = Me![Batch Number] rs("Date Closed") = Now() rs.Update rs.CloseElse 'never enters, jumps to Error label 'Batch already listed in table MsgBox ("Batch already in table. Updating Closed date")End IfErr_cmdHoldStatus_Click: MsgBox Err.Description
This is what the debugger outputs for my values Code:Me![Batch Number] : 81697 : Object/Textbox rs("Batch Number") : "81697" : Object/Field rs.BOF : False : Boolean rs.EOF : False : Boolean