Creating IIF Statement In Between Statement For Dates?
Apr 28, 2015
I am creating a multi-search form for a student database, where after I enter my search criteria I hit a "Run Query" command button and then it opens a query form with all of my criteria.So far I can search using last name, first name, and middle name. When I try to search with a start date and end date I am have issues.The start date and end date is for the class date. In the query form under the field, class date, for criteria I wrote:
Between IIf([Forms]![Search Form]![Start Date]="",1/1/10,[Forms]![Search Form]![Start Date]) And IIf([Forms]![Search Form]![End Date]="",4/25/15,[Forms]![Search Form]![End Date])
I want it when I write a date in the start date and end date I want it to give me a list of all the students who took the course between those dates. Also, if I leave the dates blank I want it to search all dates. The dates 1/1/10 and 4/25/15 are just the dates I gave because that is far back as my database goes.
I have created a database that tracks employee adherence. We have employees monitor adherence and when someone is out of adherence we track the time they are out and also there shift time. I am needing Access to know to change a record from 0:00 (midnight) to 23:59. I know it is probably done with an IF statement but dont know how to write it correctly, or where to place it.
Now, I know that something in the UPDATE statement does not match my select statement.What should my Update Statement be, in order to update all the columns in the joined tables?
Why doesent this work aa = Me.Due aa = DateAdd("m", aa, Date)
Tasklist.RowSource = "SELECT [Tasks].Staff_Name, [Tasks].Project_Title, [Tasks].Percentage_Complete FROM [Tasks] WHERE [Tasks].Date_Allocated < " & aa & " ORDER BY [Tasks].Staff_Name;"
I have an online Access database and dont want to have to take it offline (download, update, upload) to create a new table.
Therefore I want to use a CREATE statement that I can run via an ASP page to create any additional tables.
I don't want to have to create the statements by hand so im looking for a way to create a table on my local version of access and export the SQL statement that would be used to create this table.
I am quite new to access 2007 but trying to create an IIF statement in a report but don't know where to start.
My report has lots of 'Label' fields with standard text based on a query for the fields components. I want one of my labels to only appear on the report for print IF a record field called 'Program' (which is from a list) has the word 'RHICHOP' at the beginning of it. If RHICHOP is not in the beginning of the Program then leave out the label text.
how to use the Like statement when creating a record-set of data through VBA. Before I was always able to find work-arounds but now is the time to slay this issue once-and-for-all.A person can build several sales quotes for a specific company and I am trying to find the last sales quote that was built. The function is passed a variable length string and I am trying to build a recordset of all quotes based on the variable. Here is the offending line of code:
strSQL = "SELECT * FROM Quotes WHERE Quotes.ProposalNo Like " & "*" & strProposalBase & "*" & " ORDER By Quotes.QuoteID DESC" (This yields an empty recordset)
strSQL = "SELECT * FROM Quotes WHERE Quotes.ProposalNo Like ""*" & strProposalBase & "*"" ORDER By Quotes.QuoteID DESC" (This yields an Error message stating there is an invalid column name)
strSQL = "SELECT * FROM Quotes WHERE Quotes.ProposalNo Like " & strProposalBase & "*" & " ORDER By Quotes.QuoteID DESC" (This yields an Error message stating there is incorrect syntax near the word ORDER)
I have tried different variations above and beyond these strings and get one of the three listed errors.
I'm trying to calculate the number of days between two dates using the iif statement
Fields: [LDW] "Last Day Worked" [ReturnedDate]
DESCRIPTION: If ReturnedDate is null, then calculate the datediff "d" between LDW with Now(), if not, then calculate the datediff "d" between LDW with ReturnDate.
I tried this but it didn't work at all.
Days Absent: Iif(isnull([ReturnedDate],(DateDiff("d",[LDW],Now())),(DateDiff("d",[LDW],[ReturnedDate])))
I'm trying to build a query with an iif statement to calculate expiration dates within a query. For some reason what i'm trying to do is not working as expected.
Here's the situation. Every employees with an exception of two employees in the company has an expiration 2 years after the class took place. The two exceptions are the certified instructors who's training certification is good for three years.
I've created a query with the employeeid, training subject, and maxoftraining date.
I'm trying to write an if statement to give me the expiration date based on the above information. Here's what I have so far; however its not calculating based on the criteria.
Expiration: IIf([tblemployee]![EmpID]=1 Or 2,DateAdd("yyyy",3,[maxoftrainingdate]),DateAdd("yyyy",2,[maxoftrainingdate]))
At this point in time, all "expiration" dates are showing + 3 years rather than just the Employee ID's 1 and 2 and the rest +2 years.
My issue is that I am trying to update a date field. When I do the date field may have a date or may be a null. When I try to pass in a NULL date with no quotes, I get a syntax error. When I have single quotes in the statement and a null value is passed in, I get an invalid use of date.
Dim DENIEDDATE1 As Date If (Not IsDate(rs.Fields("DENIED_DATE"))) Then DENIEDDATE1 = Null Else DENIEDDATE1 = "'" & rs.Fields("DENIED_DATE") & "'" End If
update table1 set table1.denieddate = " & denieddate1 & " 'get Update syntax error with this statement update table1 set table1.denieddate = '" & denieddate1 & "' 'fails due to invalid use of null
creating dynamic RibbonXML where statement will depend on user that is accessing access database. I created DynamicXML no problem and it changes context depending on user but my main problem is refreshing ribbon. I see that UsysRibbons tables changes fine but it's not being loaded. I have to restart access in order to this to take effect. I tried gobjRibbon.Invalidate method but it doesn't refresh ribbon for some reason... Here is my code:I created new module with name "Ribbon" and put this in there:
Option Compare Database Option Explicit Public gobjRibbon As IRibbonUI Public Sub CallbackOnLoad(Ribbon As IRibbonUI) ' Callbackname in XML File "onLoad" Set gobjRibbon = Ribbon End Sub
and then in form that validates a user I put:
If (Not gobjRibbon Is Nothing) Then gobjRibbon.Invalidate End If
I am trying to calculate a value based on comparing the current date to the dates in these fields. I am using the below formula. However, using 6/27/2013 as the current date, my formula keeps resulting in "Bronze" when it should result in "Standard" Am I doing something wrong?
=IIf(Date()<[Bronze],"Standard",IIf((Date()>=[Bronze]) And (Date()<[Silver]),"Bronze",IIf(Date()>=[Silver] And Date()<[Gold],"Silver",IIf(Date()>=[Gold] And Date()<[Platinum],"Gold","Platinum"))))
'WHERE ((OperationalRiskEventTable.DateReported)>=Forms!U pdateForm!UDateBegin And (OperationalRiskEventTable.DateReported)<=Forms!Up dateForm!UDateEnd)'
in a query by form.
The problem is that you have to enter a date in the between values for results to show. If I don't enter information into a different field such as Full Name but I enter in 40 into Age then everyone that is 40 years old will show. On the other hand if I enter 40 into the Age field but I leave the Date Reported fields empty then no results will show.
How can I change it so that I don't have to enter dates into the date reported fields for results to show?
I have a query with the following criteria in one of the fields:
>=DateAdd("m",-12,fom()) And <=DateAdd("m",1,fom())
fom is a function for first of the current month. I need this query to be specific to what month it is when its ran so i want to only have this criteria if the month is > = october. If it isnt October or greater, i want the criteria to reflect this.
>=DateAdd("m",-12,fom()) And <=fom()
Which also works by itself. But when i add it to an iif statement it always produces no results. Below is the iif statement.
Iif(month(date())>=10, >=DateAdd("m",-12,fom()) And <=DateAdd("m",1,fom()),>=DateAdd("m",-12,fom()) And <=fom())
I have also added the column name to each expression and it still doesnt produce any results.
I have a text box that I'm trying to control the color of based off an IF then statement. Based off to If's
If [Reports]![Rpt-Paths]![subreport].Report![ModuleCh] = "Ch - A" And [Reports]![Rpt-Run Paths]![subreport].Report![Status] = "0" Then
This part works but I need to add a second one
If [Reports]![Rpt-Paths]![subreport].Report![ModuleCh] = "Ch - B" And [Reports]![Rpt-Run Paths]![subreport].Report![Status] = "0" Then
So I want the text box to be RED if the status of both Ch A and Ch B is 0 but if either one has a status greater than 0 then the text box would be green.
I'm using this code to do some calculations on a form. This code works fine as long as only one IF statment is true. My problem starts when the one of the values is equal (meaning qual is 4) so I try to add < or = to and then I end up with more then one IF statement being true. Is there a better way to do this?
If Me.[qual] < 4 And Me.[completed] < 61 Then Me.[GtoG] = [GtoGtotal] Else End If If Me.[qual] < 4 And Me.[completed] > 61 Then Me.[GtoG] = Me.[qual] + 61 Me.[temp1] = Me.[completed] - 61 Me.[Delayone] = Me.[Delayone] + [temp1] Else End If If Me.[qual] > 4 And Me.[completed] < 61 Then Me.[GtoG] = Me.[completed] + 4 Me.[temp2] = Me.[qual] - 4 Me.[Delaytwo] = Me.[Delaytwo] + [temp2] Else End If If Me.[qual] > 4 And Me.[completed] > 61 Then Me.[GtoG] = 65 Me.[temp1] = Me.[completed] - 61 Me.[Delayone] = Me.[Delayone] + [temp1] Me.[temp2] = Me.[qual] - 4 Me.[Delaytwo] = Me.[Delaytwo] + [temp2] Else End If
I am trying to do something really simple, but my lack of experience in Access has bitten me. I have a report... there is a field called payor_code and one called bill_time. These are both based on tables.
The variable is payor code... it could be 2 different things.
All I want to do is make a calculation for TOTAL that multiplies the bill time, times the correct rate. (which is determined by the payor code)
I want to basically do this:
If payor_code = "02" Then total = Bill_Time * 1 Else total = Bill_Time * 2
Question..... i have a report in access on which grades of student are shown, like the following example:
Lifescience 6 Brainstorming 7 learningdev. 9 communication 5
My goal is to, next to the grades, also to put the grades as words...
Lifescience 6 six Brainstorming 7 seven Learningve. 9 nine Communication 5 vife
I have no clue actually how to do that, i of course thought of an IIF statement, the only thing i know is the crystal reports syntax, but in this case i am not sure how to 'translate' it to the expression on the field. (that is: i think i have to use the field where the grade comes from?)
Thanks for this, i think, relatively simple question........
Ok guys, I am stuck. If I have the following codes that works fine when I separate each "IF" statement, but I was trying to combine it all into one code. When I combine the code, I continue to get the msgbox even when the criteria has been met. Please tell me what I am doing wrong. Just trying to simplify the codes.
If Me.cboFat = 1 And Not IsDate(ClosingDate) Then MsgBox "Based on your selection in the Final Action Taken, Closing Date is a required field!" Cancel = True End If
If Me.cboFat = 2 And Not IsDate(ClosingDate) Then MsgBox "Based on your selection in the Final Action Taken, Closing Date is a required field!" Cancel = True End If
If Me.cboFat = 3 And Not IsDate(ClosingDate) Then MsgBox "Based on your selection in the Final Action Taken, Closing Date is a required field!" Cancel = True End If
If Me.cboFat = 4 And Not IsDate(ClosingDate) Then MsgBox "Based on your selection in the Final Action Taken, Closing Date is a required field!" Cancel = True End If
If (Me.cboFat = "1") Or Me.cboFat = "2" Or Me.cboFat = "3" Or Me.cboFat = "3" _ Or Me.cboFat = "4" And Not IsDate(ClosingDate) Then MsgBox "Based on your selection in the Final Action Taken,Closing Date is a required field!" Cancel = True End If
I'm trying to calculate the value of a field based on the other columns in the table. It's working in a form but I need to save the value in the table. I'm selecting the default value of the field and entering the following:
IIf(DateDiff('m',[Vesting Start Date],Date())>12,0.25*[Number of Options]+(DateDiff('m',[Vesting Start Date],Date())-12)*0.03*([Number of Options]-(0.25*[Number of Options])),0)
It doesn't recognize any of the column names like Vesting Start Date. Is it possible to calculate the value of a field based upon the other columns?