Queries :: Correct Syntax / Expression For Log Of Number
Mar 23, 2013Correct syntax/expression for log of a number. The number i am getting in Access is twice as big as the correct number i get in excell
View RepliesCorrect syntax/expression for log of a number. The number i am getting in Access is twice as big as the correct number i get in excell
View RepliesI have the following code with dcount
If DCount("Username", "[tbl_userinformation]", "[Username] = " & Me![Text146] & " AND [actualdate]=" & Me![Text148] & " ") > 0 Then
but i have the following error ...
runtime erro 3075: syntax error in number in query expression '[username]=f15691b and [actualdate]=13.04.2015'
f15691b and 13.04.2015 are the values those i entered.
I am creating a database to analyze prices. I have 2 tables. One table has a bunch of dates, product names and the prices. There are many of the same dates and many of the same products. I.E. a product could get priced one day and than have a different price the next day.The other table has a bunch of information and dates and product names also. The goal is to add a week to the dates in this table and use that date and product name to look up the corresponding price for that date and product and add it to the record.
I am trying to use Dlookup but evey record is then filled with the same price. I am using this Expr1: DLookUp("Price","Qry_Historic_Price","[Date]=#[End Period]# And primary_id ='[primary_id']")...When I run the query I get a message that says "Syntax error in query expression" than a message box that pops and says "Unknown" with only "ok" to click.
Access and receive the following message after trying to run a query: Syntax error (comma) in query expression, followed by the formula I wrote on the Query Builder. I use 4 tables to run the query, but only need to trim some stuff from one of them. This table is called BD_lamosa_corregida and have already selected Expression on the Total row in Design View. This is the formula:
parte: Trim(IIf(IIf(IsError(InStr(1,[Parte],"(",1)),"",InStr(1,[Parte],"(",1))="",[Parte],Left([Parte],IIf(IsError(InStr(1,[Parte],"(",1)),"",InStr(1,[Parte],"(",1))-1)))
The formula is trying to trim the left side of an expression (Part description) which may contain a code number in parenthesis or not, it might also have this parenthesis separated by a space or not.
The code I have is.
Code:
Private Sub Command26_Click()
If Forms![test site]![prp test].Form.[A Right Answer] = -1 Then
Forms![test site]![number correct] = Forms![test site]![number correct] + 1
End If
DoCmd.FindNext
End Sub
Then when clicked it checks a yes/no box to see if "A right Answer" is the correct yes. Then it should pop to the main form and take the number correct cell and add one to it. I am trying to get the record to go to the next record inside the sub-form but docmd.findnext seems to be wrong too.
I'm trying to run a very basic iif statement to correct hourly data for sorting. Basically, a trading day runs from 8am - 8am, so I need to adjust the hours to ensure that 1am on the 15th trading day (really the 16th on the calendar), comes after 9am on the 15th trading day (which will actually be the 15th on the calendar).
Here's what I've used. It's driving me bananas, because it keeps telling me that there's a syntax error (comma) in the query expression, but I can't understand why?
Sort2: IIf([DELIVERY_HOUR]<8,[DELIVERY_HOUR]+24,[DELIVERY_HOUR])
I am trying to get Average If function to access sql. I have columns Period and Costs_Per_Capita, result should be like like this:
Costs_Per_Capita Period CALCULATED_Period_Avg_Costs
15,505 1 15976.27582
16,368 1 15976.27582
16,037 1 15976.27582
15,995 1 15976.27582
15,000 2 16000
17,000 2 16000
I tried:
SELECT Costs.Costs_Per_Capita, Costs.Period
IIF (Period = 1, (Select AVG(Costs_Per_Capita) From Costs Where Period = 1),
(Select AVG(Costs_Per_Capita) From Costs Where Period = 2)
AS result
FROM Costs;
But get "syntax error (missing operator) in a query expression ..."
End result query example:
Between #10/15/04" And #10/15/04# - 6
Or the date range of 10/10/04 through 10/15/04
This would be in a query under the Date field
What is the correct syntax? Please include
() and # signs where they need to be.
Thank you.
This is what I'm trying to fit into the control box. Maybe there is a much better way to do it so suggestions are very welcome. I don't know if I can even use "!" in the IIF statement. And I think it's too long, so it's invalid.
What I'm trying to do is to check if all those fields are passing (or NOT failing). Then insert "Yes" or "No" into a textbox.
----------------------------------------------------------------
Code
----------------------------------------------------------------
IIF(blackStartPlans!=”fail” and operatorTraining!=”fail” and telemetryAvailable!=”fail” and backupControlCenter!=”fail” and vegetationManagement!=”fail” and capacityEmergencies!=”fail” and cat_A_contingency!=”fail” and cat_B_contingency!=”fail” and cat_C_contingency!=”fail” and cat_D_contingency!=”fail” and electricityFacRating!=”fail” and relayMaintenance!=”fail” and UFLS!=”fail” and UVLS!=”fail” and Other!=”fail”, “Yes”, “No”)
I've created several expressions in a query to test for values in a field (one column for each value for use in a report).
The expressions output the value 1 where the test is true. I planned to sum them to establish how many times the value is true but this isn't working. I am only offered a Count and this returns the number of records. Other fields (numeric) are offering me a sum at the total line and are working as expected.
I assume the expressions are outputting the value one as text rather than as a number but I can't work out how to change this.
what is the correct syntax to write a command line able to UPDATE more than one field in the table records having multiple WHERE criteria.
Here is my challenge:My TableI has the columns A, B, C and D which are populated, for example, as follows:
TableI
A B C D
1 2
2 6 4 3
1 7 5 9
1 2
2 5 8 5
etc.
I also have a FormII which updates TableII. Among the existing fields of TableII there are the fields C and D (same as above). When saving data entry thru the save button of the FormII, fields C and D will be naturally saved on the TableII. Well, I also want C and D info updated into Table I as well, but only when field A=1 and B=2.So what I need (for the click event of the button save in the FormII) is to open TableI and either insert or update it with the values of the fields C and D in every record WHERE A=1 AND B=2.For instance, assuming C=& and D=%, the desired result should be as follows:
TableI
A B C D
1 2 & %
2 6 4 3
1 7 5 9
1 2 & %
2 5 8 5
I did not find any examples in the net including multiple criteria..Here is what I wrote unsuccesfully:
Private Sub BtSalvarFrmII_Click()
CurrentDb.execute "UPDATE TableI"
Set FieldC = Forms!FrmII!FieldC.value AND Set FieldD = Forms!FrmII!FieldD.value WHERE FieldA = 1 AND FieldB = 2
Docmd.save
Docmd.close
End Sub
What would be the correct syntax?
I've been staring at this for a while and have had no luck, anyone able to assist?
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
Set Conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
sql = "INSERT INTO COMMENTS (TXT,MODIFIED,PID,P_SCHEDULE,P_BUDGET,P_SCHEDUAL_C OM,P_BUDGET_COM) Values (" & Forms!PROJECT_EDIT!comments & ", Now() , " & Forms!PROJECT_EDIT!PID & " , '" & P_SCHEDULE_VAR & "' , '" & P_BUDGET_VAR & "' , '" & Forms!PROJECT_EDIT!P_SCHEDUAL_COM & "' , '" & Forms!PROJECT_EDIT!P_BUDGET_COM & " ' ;)"
Conn.Execute sql
The error is point it too the end of the document
Thanks in advanced
Hello.
I've managed to create an access-database and (fill it with some data), retrieve data from it with asp, but
when I try to insert or update data with asp, I get the same error:
"Syntax-error in Insert expression" or "Syntax-error in update expression"
Do I have to "chmod" the database to write to it, or what?
(I usually work with sql-databases, and the code/syntax I believe is not wrong,as it works on another database)
Conn.Execute("INSERT INTO tour(date,venue,city,link) VALUES('" & datum & "','" & venue & "','" & city & "','" & link & "')")
Thank you in advanced for answering my query.
//Joakim
Hello, first time posting, not sure what info you all need. I'm looking for some help with an if/then statement in access query involving dates. Below is the query I am trying to use, along with the error message. Any ideas?
Domestic Violence CME Required?: IIf(([Date of Next Medical License Renewal]-[Date of Last Domestic Violence Credit (2)])>("yyyy",6),"yes","no")
syntax error (comma) in query expression 'IIf(([Date of Next Medical License Renewal]-[Date of Last Domestic Violence Credit (2)])>("yyyy",6),"yes","no")'
The error seems to be in relationship to the number 6. I want a "yes" to show up in the field if the difference is greater then 6 years.
Hello I'm having trouble getting my nested Iif statement to run. Can anyone help??? I've attached a screen shot of the syntax error that I'm receiving. The example code below needs tweaking.
Update [Goodrec-copy3] set [Goodrec-copy3].shortname = Iif (Not Null([shortname]),[Goodrec-copy3].shortname Like "*,JR*" Or ([Goodrec-copy3].[shortname] Like "*, SR*" Or ([Goodrec-copy3].[shortname]) Like "*, II*" Or [Goodrec-copy3].[shortname]) Like "*, III*", InStrRev([shortname])," ",InStr([shortname]," ,")+1,50) &" "& Left([shortname],InStrRev([shortname])," ,")-1) WHERE ((([Goodrec-copy3].[ctype])="I"));
What I'm attempting to accomplish with this query is to keep the field shortname the same if not null and if it doesn't meet the criteria of having a string value of "JR", "SR", "II", or "III". If the field does have a string value of "JR", "SR", "II", or "III" reverse the string (example John Gissom JR) to reflect shortname as such for example: "Gissom JR John".
Thanks in advance!
Morning all
The problem whihc i have is that, when trying to open the form "Create Timetable", through the switch board.... a message box appears saying "Syntax error (missing opertor) in query exprssion"
Any ideas on why it is showing this message box???
Help would be appricated
Thank you
I have an asp page which modifies articles in my access database.
I added a field in the db called "Blocco" which is a checkbox field.
The code (working) which the page used before was (I'm copying just the part that modified will cause the problem):
Code:SQLModifica = " UPDATE [Articoli] SET Articoli.Sezione = '"& FSezione &"', Articoli.Autore = '"& FAutore &"', Articoli.Titolo = '"& FTitolo &"', Articoli.Podcast = '"& FPodcast &"', Articoli.tags = '"& Ftags &"', Articoli.Data = '"& FData &"', Articoli.Ora = '"& FOra &"', Articoli.Letture = "& FLetture &", " If FBozza = "si" ThenSQLModifica = SQLModifica & "Articoli.Bozza = True "ElseSQLModifica = SQLModifica & "Articoli.Bozza = False "End IfSQLModifica = SQLModifica & "WHERE Articoli.ID = "& FID &" "If Session("BLOGAdmin") = False ThenSQLModifica = SQLModifica & "AND Articoli.Autore = '"& Session("BLOGNick") &"' "End IfSet RSModifica = Server.CreateObject("ADODB.Recordset")RSModifica.Open SQLModifica, Conn, 1, 3Set RSModifica = Nothing
After adding a radio type field in the form called Blocco (with yes or no values, working like the existing field "Bozza") I've modified the code adding something to update the db:
Code:SQLModifica = " UPDATE [Articoli] SET Articoli.Sezione = '"& FSezione &"', Articoli.Autore = '"& FAutore &"', Articoli.Titolo = '"& FTitolo &"', Articoli.Podcast = '"& FPodcast &"', Articoli.tags = '"& Ftags &"', Articoli.Data = '"& FData &"', Articoli.Ora = '"& FOra &"', Articoli.Letture = "& FLetture &", "If FBlocco = "si" ThenSQLModifica = SQLModifica & "Articoli.Blocco = True "ElseSQLModifica = SQLModifica & "Articoli.Blocco = False "End ifIf FBozza = "si" ThenSQLModifica = SQLModifica & "Articoli.Bozza = True "ElseSQLModifica = SQLModifica & "Articoli.Bozza = False "End ifSQLModifica = SQLModifica & "WHERE Articoli.ID = "& FID &" "If Session("BLOGAdmin") = False ThenSQLModifica = SQLModifica & "AND Articoli.Autore = '"& Session("BLOGNick") &"' "End IfSet RSModifica = Server.CreateObject("ADODB.Recordset")RSModifica.Open SQLModifica, Conn, 1, 3Set RSModifica = Nothing
The page itself is loaded with no errors but when the form takes action I get this:
Syntax error (missing operator) in query expression 'True Articoli.Bozza = False'.
why? I've just used the same code that worked with the field "Bozza" (which is a checkbox field too)
Sorry for my english
I'm experiencing a error when I go to add a filter, "Syntax error in string in query expression "MyFieldName""..If I go to to the table where the field is located, I CAN apply a filter.However, If I throw this single field on a form and switch to datasheet view, all of a sudden I can not filter it.
Additional info: whenever I go to build a query with the field, it throws brackets around this field and no others... this is weird.
Code:
SELECT MyTable.field1, MyTable.field2, MyTable.[problemfield]
FROM MyTable
Why am I receiving 'Syntax error (missing operator) in query expression' error message ? Below is the code.
stFrmName = "Previous Plan"
stLinkCriteria = "(Employee = " & strPreviousTeacher & ") And (Record_Date = " & strPreviousDate & ")"
DoCmd.OpenForm stFrmName, , , stLinkCriteria
I've come across a simple error that has me baffled. I continue to receive the run time error 3075: Syntax error (missing operator) in query expression 'tblMasterPersonnel.FirstName"042" Or (tblMasterPersonnel.EmpID)="044"))'
Here is the strSQL
Code:
strSQL = " SELECT tblMasterPersonnel.EmpID, qryiuSSN.SSN, ""SSN"" AS [ID Type], """" AS TXN, tblMasterPersonnel.LastName, " & _
"tblMasterPersonnel.FirstName, tblMasterPersonnel.MI, """" AS Suffix, IIf([tblMasterPersonnel].[Gender]=True,""F"",""M"") AS Gender, " & _
"tblMasterPersonnel.Birthday, tblMasterPersonnel.PlaceBirth, """" AS [Country Code], """" AS Country, tblAddresses.Phone1, " & _
"tblAddresses.Street, tblAddresses.City, tblAddresses.State, tblAddresses.Zip, tblAddresses.Country, " & _
[code]....
I am trying to convert an excel formula into the expression builder on my form.
the excel formula is this:
IF(AND(E4>=2.65,F4<1.85),"Poor",IF(AND(E4<2.65,F4< 1.85),"Unacceptable",IF(AND(E4>=2.65,F4>=1.85,F4<2 .65),"Generally",IF(AND(E4<2.65,E4>=1.85,F4<2.65,F 4>=1.85),"Poor",IF(AND(E4<1.85,F4<2.65,F4>=1.85)," Unacceptable",IF(AND(E4>=3.45,F4<3.45,F4>=2.65),"H igh",IF(AND(E4>=2.65,E4<3.45,F4<3.45,F4>=2.65),
[Code] ....
In the expression builder I put this:
= IF(AND( [Objective Total] >=2.65, [KSF Totals] <1.85),"Poor",IF(AND( [Objective Total] <2.65, [KSF Totals] <1.85),"Unacceptable",IF(AND( [Objective Total] >=2.65, [KSF Totals] >=1.85, [KSF Totals] <2.65),"Generally",IF(AND( [Objective Total] <2.65, [Objective Total] >=1.85, [KSF Totals] <2.65, [KSF Totals] >=1.85),"Poor",
[Code] ....
It gives me an error 'expression you entered contains invalid syntax, you may have entered a comma without a preceding value.'
Wondering if anyone can advise...
The 1st/2nd Jan of this year were treated by most people as still being week 53 of 2004, and week commencing 3rd January being week 1 of 2005. In VB I have a formula to do this:
WeekNo = Format(Now(), "ww", vbMonday, vbFirstFourDays)
However my problem now is that I need to replicate this format in a Query within Access. The formula
WeekNo: Format(Date(),"ww")
treats 1st/2nd Jan as week 1, the 3rd as week 2 etc. Any idea how I can get it to treat 3rd Jan as week 1 instead?
There's a challenge for someone!! Help appreciated.
I am having trouble with the below returning the correct number of records, and can't see why.
I have one table, tblDevice, which has 4 columns, ID | DeviceRecNo | ExcludeFromCheck | StockLocationID
ID - Autonumber
DeviceRecNo - Number
ExcludeFromCheck - Number (1 = yes, 0 - No)
StockLocationID - Number
I have the following running as part of some code, but it is not returning the correct number of records, and I cant see why not. I have tried creating this in a query in Access itself, and copy the SQL into VBA and it still doesn't return the correct number records.
I have 4 records in there for testing, all with StockLocationID = 3, all with different DeviceRecNo, and two each of ExcludeFromCheck, 2x0 and 2x1
Code:
Public Function test()
Dim db As dao.Database
Dim rs1 As dao.Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("SELECT DeviceRecNo FROM tblDevice WHERE StockLocationID = 3 AND ExcludeFromCheck = 'No'")
Debug.Print rs1.RecordCount
End Function
I have created a form based on a query. The funny thing is when I tried to sort fields on the form, the following message box pops up:
Syntax Error (Missing Operator) In (Field Name)
I just did the exact same thing several weeks ago, and that first form could sort fields normally. The only difference between the first one and this is that this second query was based on several tables, while the first was based on a single table, although I doubt that is where the problem is.
I forgot to add that I could sort fields where the field name doesn't have spaces in it. For example, the field name "Customer ID" triggers the syntax error, while the field "S/N", "Company", etc. can be sorted like normal.
In a query I would like to extract the last ten years. This is what the data looks like:12/13 (Data type = text)(Short for 2012/2013 which actually represents 7/1/2012 to 6/30/2013.)
I am able to extract the "12" and turn it into the general number 2012 using: ("20" & Left([TAXYR],2))*1..But how can I convert that to the data type-date so I can include those records in the past ten years from todays date? I was trying to use DateAdd but I think the problem is the data type and where converting to date gives me "1905" or "9/##/1905." I get why it does that, but is there a workaround? Maybe adding 39,785 days?? (2014-1905)*365
I am using the IIf function as follows
Exp1:IIf(field A = "a string value",1,0) this returns the correct value.
However when I try to add a second condition using the IIf function, or use the And Or condition, I do not get the correct value.
I am trying to get a value of 1 in the Exp:Col when field B has a value that is different from field A.
What is the correct syntax? What am I missing??