Queries :: IIF Conditional Statements To Assign New Values In Table

Apr 11, 2013

I am writing some iif conditional statements in one of my tables to assign new values in that table.

Code:
FP: IIf([cohort with status].[Intake Date] Between #04/01/2012# And #26/04/2012#,201201) Or IIf([cohort with status].[Intake Date] Between #27/04/2012# And #24/05/2012#,201202)

When I run it, I am getting some -1 values in the new column FP.

but if I get rid of the second IIF, then it works.

how do you combine multiple IIF statements in a query?

View Replies


ADVERTISEMENT

Queries :: Cannot Assign Any Data Values To New Field Added To Query

Aug 12, 2015

Created a new Query (called qry_Temp) from and existing Query (qry_Test that has fields Field1 - Field5) using QueryDef , and inserted a new Field (FieldX) into it (see example below) using the .Parameters property, then opened a Recordset based on the new Query in order to attempt to enter data values into the new Field (FieldX) for each record in the query - but cannot assign any data values to this new Field (but can to the existing fields) in the new Query?

Dim DB As Database
Dim rs As DAO.Recordset
Dim qdfNew As QueryDef
Dim strSQL1 As String
Dim strSQL2 As String
Dim Value1 As Integer

[Code] ....

View 6 Replies View Related

Modules & VBA :: Assign Values To A Table Through Code?

Jun 24, 2015

I have a table (tblPrinterSelection) with three fields: Autonumber, DocType, PrinterSel

There are three types of values for "DocType"; "Document", "LargeLabel", "SmallLabel"

I want to assign a "PrinterSel" to each type of "Doctype", which basically means that the user selects the type of document and then the printer in a form that has the code below and then I need the code to automatically update the table.

Code:
Dim PrintSel As String
Dim DocType As String
'Assign a value to the printer selected variable
PrintSel = Me.lblPrinterSelected.Caption
If IsNull(Me.frmDocType) Then
MsgBox "No document type selected."

[code]....

What i am looking for is code that would pick the value for "DocType" and "PrintSel" assigned here and add them to the table so that I can use that info later.

I am only looking to have three rows in that table so if the "DocType" does not exist then a new row is created but if it does, only the value of "PrintSel" is updated.

I should end up with something like this:

1 Document Epson
2 LargeLabel HP
3 SmallLabel Canon

How can I do this?

View 3 Replies View Related

Conditional Statements

Aug 16, 2006

What is the best way to handle a complex conditonal statement like this? I thought about nested statements but i'm not sure if i can put all of these statements in the expression. There are some other conditions that i did not include.

If VBand = A and if CBand = A, allowed
If VBand = B and if CBand = B, allowed
If VBand = A and if CBand = A/B, allowed
If VBand = B and if CBand = A/B, allowed
If VBand = A and if CBand = A/C, allowed
If VBand = B and if CBand = B/C, allowed
If VBand = A and if CBand = A/C, allowed

If VBand = B and if CBand = C, not allowed
If VBand = B and if CBand = C, not allowed except certain areas
If VBand = A and if CBand = C, not allowed
If VBand = C and if CBand = A, not allowed except certain areas
If VBand = C and if CBand = C, not allowed
If VBand = A and if CBand = B, not allowed except certain areas
If VBand = C and if CBand = B, not allowed except certain areas
If VBand = A and if CBand = B/C, not allowed
If VBand = B and if CBand = A/C, not allowed
If VBand = C and if CBand = A/C, not allowed
If VBand = C and if CBand = A/B, not allowed
If VBand = C and if CBand = A/B/C, not allowed
If VBand = C and if CBand = B/C, not allowed except certain area

View 1 Replies View Related

How To Calculate Maximum Values From The Table And Assign To Textbox

Nov 18, 2011

I have a problem in doing a task with my form. Actually I have a button to add a new record which opens a new form there i enter the values to the record. But when I press the Addnew record button I want to calculate the maximum of the Identity field +1 and open the new form with that new number which i have calculated. How can i do this....

View 1 Replies View Related

Reports: Conditional Statements In Text Box

Mar 3, 2006

I am creating a report based off a query. My problem is that I am trying to create conditional statements within a unbounded text box. I would like to say: =[Field] where [Field2] = X. Unfortunately, I can not find any support on this matter.

View 14 Replies View Related

Modules & VBA :: Edit Conditional Statements Via Form

Aug 31, 2013

I have a table of marks of student, a query that calculates totals and a form that displays results. on the query, i have an if statement.

Code:
comment:IIf([Marks]>=80,"good",IIf([Marks]>=50,"fair",IIf([Marks]>=40,"Work harder")))

So i want to be able to make the whole syntax available for user to edit without actually doing it in vba. is this possible in vba? i have attached an image

View 8 Replies View Related

Tables :: Conditional Values In The Table?

Jan 30, 2013

I have two tables "Funds" and "Classes" with one-to-many relationship, resp. (through the "Fund_name" fields). There is the field "Active" in the "Funds" table and the field "Open/Closed" in the "Classes" table. What I would like to do is to put "No" value into the "Active" field record if the corresponding (with respect to the relation of course) "Open/Closed" field records have all values "closed". Otherwise put "yes". Is there any way, how I could make this?

View 14 Replies View Related

Queries :: Get Values From One Query And Assign Them To Another Query

Dec 18, 2014

I have created a query that counts the AppSizerPerUD for every User Drive (UserDriveID). Now I want to assign these values to the other query (UserDrive Usage) for every UserDriveID. So I want to create a new column in the UserDriveUsage query that will contain the AppSizePerUD. In this case in the first two rows must be 23.6, then one row 18.38, the third one 45,39 etc.I need something like a VLOOKUP in Excel. I have tried DLOOKUP but probably I am not uisng it correctly.

View 3 Replies View Related

Null Values And Like Statements

Aug 8, 2005

I am using a query with Like statements that looks at a field in a form. The form defaults to "*" so that all of the records will show. You can search with the normal wildcards. The problem I have is that the records containing Null values don't appear. I was trying to see if I could use an IIF statement in the criteria of the query, but have had difficulty. What is the proper way to have all records show if * is the default, but only the specific criteria if something is entered using wildcards?

View 5 Replies View Related

IIf Statements And NULL Values

Apr 10, 2007

Within my query I have a field that I need to do a nested IIf Statement that has a NULL value. The name of the field is "smokingcessation". The possible responses are a "1" = Yes, "2"= No, "3"=Unknown and there is also the possibility of a "no answer" at all (blank). I've got the following statement to work so far but need to include the possibility of a blank/no answer response. My statement so far is as follows and is working:

IIf([smokingcessation]=1,"Yes",IIf([smokingcessation]=2,"No","Unknown"))

How would I do a statement that would take into account the existing possibilities plus that of a blank (NULL) answer and leave the field blank in that case? In otherwords, I need to see a "Yes", "No", "Unknown" or a blank field.

Thanks for any help in advance.

View 6 Replies View Related

IF Statements With NULL Values

Jul 23, 2007

I've written a query that is assigned either a pass/fail depending on certain criteria. Here is the query:

Pass/Fail: IIf([jc_actlevel]="Yes" And [jc_diet]="Yes" And [jc_medications]="Yes" And [jc_followup]="Yes" And [jc_sympworse]="Yes" And [jc_weightmonitor]="Yes","Passed","Failed")

I want this query to only show me records that have a "yes" or "no" value but some on the records have neither a "yes" OR "no" (just a NULL value)and are showing up in the query as "failed" which is throwing off my count of how many records met the pass/fail criteria (see attached).

How can I NOT show records that have a NULL value in my query? Thanks for any help.

View 1 Replies View Related

Modules & VBA :: Using Parameterized Values In SQL Statements

Oct 15, 2013

I've seen a common solution is to double up the apostrophe, replacing ' with " to avoid the special character however i also hear of another solution using "parameters".I tried have a look around on the internet and got confused so I thought maybe it would be better to ask here.

I just want to change my INSERT INTO and UPDATE commands to be able to use this (to prevent a potential sql injection) also i think its important to know im using DOA to code? (not sure if its important) either way.

View 3 Replies View Related

Assign Default Values

May 16, 2006

Hi, in my database I have a 7 subforms that shows fields for daily tasks for each day of the week. On the Monday, the tasks are assigned and then stored for every record for the corresponding date. The process is done again on tuesday, then wednesday etc. However, often the daily tasks for say tuesday will be very similar (sometimes the same) to that of monday's.

Therefore is there a way to set the default values for each day as the previous days tasks and then alter them if needed?

Thanks for helping!:o

View 1 Replies View Related

Forms :: How To Assign Values In Combo Box

Nov 1, 2014

I am new to access. In a form, I have a combo box(combo1) that store values in field(remarks1) in a table.The values in combo box are:

SL
ST
DI
SL + ST
SL + DI

These all values are being saved in remarks1 quiet easily. I have more fields in the table:

SL1
ST1
DT1
SLST1
SLDI1

I want when I selet SL from combo1 it saves SL in remarks1 and save "1" as well in SL1 field.I want to have same result with all five combo1 values

View 2 Replies View Related

Queries :: Calculation Based On Values Selected In Table By Looking Up Corresponding Values In Other Tables

Aug 29, 2014

I'm using Access 2010. I need to calculate a score based on values selected in a table by looking up corresponding values in other tables. I have a "Project" form to create new entries into the Project table (see Table 1). When I create a new project record, I will select values for the Payback and Need fields by selecting options from a list. The Payback list is pointed at Table 2 and the Need list is pointed at Table 3. In the below example, I created the "ABC" project and selected "1 year" for the Payback field and "Repair" for the Need field. Pretty simple.

Now that I have the "ABC" project loaded to my Project table, I'd like to create a report that will show a "score" for this project. The score should be calculated as follows: Payback Impact + Need Impact. In this example, the score should be 30 (Payback Impact of 20 + Need Impact of 10).

View 5 Replies View Related

Queries :: ORDER BY - Update Values In One Table With The Values In Another Using Join

Sep 18, 2013

I have a query with an INNER JOIN and ORDER BY that is working great. Now, using the same JOIN, I need to update values in one table with the values in another. I thought it would be simple until I learned you can't do an ORDER BY with an UPDATE. Is there another way to achieve the same result? If you remove the 'ORDER BY', the statement below doesn't produce an error but the results are not correct:

UPDATE TableA INNER JOIN TableB ON (Left(TableA.CDN,6))=(TableB.CDN)
SET TableA.HCC = TableB.HCC
WHERE TableB.HCC Like '241*' AND TableB.BBB = 'X' AND TableA.CCC = "1234" AND TableA.HCC IS NOT NULL
ORDER BY TableB.HCC, TableA.CDN;

View 2 Replies View Related

Use List Box To Assign Multiple Values To Records?

Jan 12, 2005

I hope the title actually conveys what I'd like to do.

I want to assign records on a subform to a group header on a form. For example, I have groups A, B, C, and D and I want the records on a subform to be assigned to groups A, B, and D. (The number of groups and their names will change so I can't simply use an "A," "B," "C" option box.) My idea is to have a Multi-Select List Box on the main form and choose all the groups to which the records on the subform need to belong. So I'd select the groups, enter the records on the subform, then create a another record on the master form and assign records to another group.

Is it possible to make this happen without a lot of programming?

View 2 Replies View Related

General :: Assign Values Evenly And Randomly?

Oct 9, 2013

We will have around 100 people attending a program that will be broken into 7 (A-G) evenly. I would like to be able to have my database do this but I am unsure of where to start on this.

View 5 Replies View Related

Queries :: Rename Field Values With Values From Another Table

Mar 2, 2015

I have two tables.descriptions I'd like to relate and use to find/replace in bulk.

[Checking].[Description] (with the source data)
[Rename].[NewDescription] (with the correct data)

I'd like the values in [Checking].[Description] to be replaced with the values in [Rename].[NewDescription], including those that are "Like".

Examples:
[Checking].[Description] = Geico 12345
[Rename].[NewDescription] = Geico

[Checking].[Description] = Geic
[Rename].[NewDescription] = Geico

View 4 Replies View Related

IF Statements In Queries

Jul 6, 2007

I have a query that is called up when data is selected from a form and you hit the submit button to go get the report. The report calls up the query which all is working except the if statement in the query criteria. Here is a look at the code.

Like IIf(IsNull([Forms]![TPKG_Status_Generator]![System_List]![column(1)]),"*",[Forms]![TPKG_Status_Generator]![System_list]![column(1)])

What it should do is if the field selection in the form is left blank and they hit submit then the query should return everything. If they pick a system number then it should only display the items in the query that have to do with that system. My problem is that no matter if I leave it blank or pick and item in the drop down box it still displays every line item. Any thoughts?

View 2 Replies View Related

Queries :: Multiple If Then Statements In Query

Jan 30, 2015

I have a query that I just can't figure out. We are a facility that works on rail cars. We have over 200 cars in house at the moment and the database has a daily production report in it with the status of all of the cars.

I need a query that will pull out the "AAAA" and "XXXX" cars from the list only IF the cleaning field or the mechanical inspection or BOTH fields are blank.

View 6 Replies View Related

Queries :: Combining SQL Statements In A Query

Sep 16, 2014

I have 2 queries serving useful routines, one to filter out duplicate addresses for a mailing label routine, the second to convert tick boxes into Y/N answers for a Tab Delimited Text file export.can I combine the 2 SQL statements in the 2nd query without amending them in any way.

The SQL statements are;

FROM [Mail List] AS a
GROUP BY a.[Member ID], a.[Address 1], a.[Member Name], a.[Address 2], a.Town, a.PostCode, a.[e-News List], a.[e-Mail List], CStr([a].[Member ID])+[a].[Address 1]
HAVING (((a.[e-News List])=False) AND ((CStr([a].[Member ID])+[a].[Address 1])=(Select cStr(Min(b.[Member ID])) + b.[Address 1]
From [Mail List] as b
Where b.[Address 1] = a.[Address 1]
Group By [Address 1])));

[code]...

View 7 Replies View Related

Queries :: If Statements To Set Parameters In A Query?

Jul 25, 2013

im working in MS Access 2007.what im trying to do is have a query run specific parameters if a check box is selected. So if the check box is selected than the query filters the "Tranche" column so that the only records that shown are records that have the "Tranche" coloumn = 1.

I know this can be done either in vba code or in the criteria section of a query but i dont know that appropriete language for either.

In vba code i was able to get this far. But..... i dont know how to call the criteria line from a query?

This is my very simple unfinished code.

My query is called [Tranch Query] and the column i want to filter with is call [Tranche]. The check box is called [Check0].

Private Sub Check0_AfterUpdate()
If Check0 = True Then
'How do i set the query criteria?????
End Sub

View 8 Replies View Related

Queries :: IIF Statements - Rounding Value In Calculated Field

Mar 24, 2014

I am using access 2010. I have a query with an iif statement on a calculated field im trying to round up. ex.

Code:
TotalDiscount: Round(iif([field1]="Piece",[int]-[decr],[field2]*[field3]/[field4],3))

I get an error something like "wrong number of arguments or expression on comma.

View 2 Replies View Related

Queries :: Populate Blank Table With All Values From Another Table

Jan 23, 2015

I have two tables (Table 1, Table 2). Table 1 is blank and has the fields "Field1, Field2, and Field3." Table 2 has data and 10 different fields ("Field1, Field2", etc). I want to copy all data from the matching fields in Table 2 to the corresponding Table 1. I've tried an Update Query in design view. Did not join any records, and just a simple:

Field: Field 1
Table: Table 1
Update To: [Table2]![Field5]

This returns 0 records to update. I thought about a Make Table to override the entire Table, but that isn't working either.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved