Modules & VBA :: Multiple If Statements Into One Procedure

Jun 26, 2013

I'm trying to put multiple IF statements into one procedure like the below:

Dim Answer As Integer
Answer = MsgBox("Have You Selected The Correct Outcome?", vbCritical + vbYesNo, "Continue Request?")
If Answer = vbYes Then 'Works fine here
'The bit I can't get right

[Code] .....

View Replies


ADVERTISEMENT

Modules & VBA :: Procedure Declaration Does Not Match Description Of Event Or Procedure

Jul 31, 2014

I have just made a change to one of the forms by adding a button (by copying the only other button on the form) to cancel any changes and close the form. However, as soon as I added it I started getting the error message in the title. Please attachment LA Err1 for the full message. I also changed the caption on the other button on the form from "Close Form" to "Save && Close Form" this button is now giving the same error.

I have Compacted and repaired the DB on several occasions to no avail. I have deleted the procedures from the module and recreated them using the properties window - still get the error. I have deleted the buttons from the form and recreated the both via the object wizard and without it. Nothing I have tried has made any effect.

View 5 Replies View Related

Multiple IIF Statements

Nov 16, 2006

I'm trying to compile a number of IIF statements.

I have 6 IIF statements, but would like to put them all in to one IIF statement.

Could anyone help me with this one?

OrderTrack: IIf([O_SRC_CD]="2005WMDT","Web","Phone")
OrderTrack: IIf([O_SRC_CD]="2005WMKE","Internet","Phone")
OrderTrack: IIf([O_SRC_CD]="DOGNET23","Web","Fax")
OrderTrack: IIf([O_SRC_CD]="CANTRY3J","Web","")
OrderTrack: IIf([O_SRC_CD]="MAMTWOSE","Web",",")
OrderTrack: IIf([O_SRC_CD]="2005W999","Web","Mail")

Thank you for your help and time

Corey

View 2 Replies View Related

Multiple If Statements, Best Way ?

Dec 15, 2004

I have a query which works fine for one if statement, but i neewd to have 10, whats the best way of sorting this, can it be done in one query, or should i use a module or should i use the code?

my if statements are as follows:

IIf([eventcode]="n204",[totaltime]-[totalcipstd],0)
IIf([eventcode]="n301",[totaltime]-[totalPaststd],0)
IIf([eventcode]="X117",[totaltime]-[totalMaintstd],0)
etc....

can someone please help me sort this...

a problem may be that the list of eventcodes may increase... again whats the best way to sort this.

Andy

View 1 Replies View Related

Multiple Sql Statements In Access Sql Editor

Jun 8, 2005

I would like to update a lot of fields in my tables; about 120 different fields in 12 different tables. I would however like to keep it simple by using the SQL editor in MS Access by writing all the UPDATE queries and leave them to run while I do smething else. It seems to me however that you can only run one query at a time using the SQL editor. I thought I could separate one SQL editor from the other by using semicolon as in Oracle SQL editor etc., but that does not seem to work. Does anybody know how to do this in Access without writing a VBA code etc.?

View 3 Replies View Related

Query Support Multiple SQL Statements

Feb 17, 2008

Hi everyone,

I am writing a query that is master-detail in principal. But need other data from other 2 tables. I wonder if I can construct the query so that it contains the result set of more than one SQL statement. Thank you for your kindly help.


Gary AU

View 1 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

Reports :: IIF Statements With AND (multiple Criteria)

May 7, 2013

I have a list of projects and I need to display their status (Red or Green) in a text box.

My fields are [PercentComplete],[StartDate],[EndDate],[ReportDate]

There are two ways a project could have a red status.

1. [PercentComplete] < 100 AND [ReportDate] < [EndDate]
OR
2. [PercentComplete]<100 AND IsNull([EndDate])

There is one way it could have a green status:
[PercentComplete] = 100 AND Not IsNull([StartDate])

This is the best I could come up with for the Iif statement, but I get "invalid argument" which I suspect relates to the AND portion.

Code:
Iif([PercentComplete] < 100 AND [ReportDate] < [EndDate], "Red",
[PercentComplete]<100 AND IsNull([EndDate]),"Red",
[PercentComplete] = 100 AND Not IsNull([StartDate]),"Green","")))

View 4 Replies View Related

Update Query With Multiple Part If Statements

Aug 13, 2014

I have a table where I have 5 columns, (BatteryL1, BatteryL2, BatteryR1, BatteryR2 and BatterySize).I want to update BatterySize, with a value if any one of the above listed columns contains a specific value using something like 'LIKE' in the query.

For example:
UPDATE Customers
SET BatterySize=13
WHERE BatteryL1 LIKE '%13%'

[code]...

View 3 Replies View Related

Queries :: Bank Holiday Date - Multiple IIF Statements

Jun 1, 2015

I've a nice formula which work the majority of the time, the only time this doesn't work is Bank Holidays. Is there a way to build on this:

>=Date()-IIf(Weekday(Date(),2)<2,4,2) And <=Date()-1

The above simply runs a report for the last working day, expect if today is a Monday then it runs Fri-Sun.

Im assuming if I know the dates of the Bank Holidays I could hardcode them into the beginning with multiple IIF statement followed by the one above??

View 1 Replies View Related

Queries :: Multiple Nested IIF Statements - Output In One Field

Mar 25, 2013

I am trying to get the output of several nested IIF expressions to show in only one filed in the table created. The output needs to be captured in a table. I am staring with create table to get it to work before I go ahead and use the sql to update the original table (the table the data is from)

I can get each to run fine independently and the whole thing runs too, the issue is it wants to put each expression in a new column, thus it is forcing me to label the expression.

Can I change this to only output in one column or add some more sql to do so?

Here is the SQL (table and filed names have been changed to protect the innocent)

BTW, I cannot change the Table the data comes from, I am stuck with the single table structure (BOO).

************************************************** *************
SELECT TABLE1.ID,
IIf([TABLE1]![STAGE]="D",
IIf([TABLE1]![PROJ_ACTUAL_D_DATE] Is Not Null,"Tier 1",
IIf([TABLE1]![APPROVAL_D]="Y","Tier 2",

[Code] .....

View 1 Replies View Related

Queries :: Missing Operator Error In Multiple Update Statements

Jun 22, 2015

I'm trying to run about 300 update statements and keep getting a syntax error of missing operator... what could be wrong?

UPDATE Applicants set [NBCC ID] = '351174' where SSN = '136861387'
UPDATE Applicants set [NBCC ID] = '350960' where SSN = '138885740'
UPDATE Applicants set [NBCC ID] = '350817' where SSN = '140082154'
UPDATE Applicants set [NBCC ID] = '351013' where SSN = '145766662'

View 11 Replies View Related

Modules & VBA :: Using If And Case Statements

Dec 16, 2013

Basically I want to check if the Reporting Month already exists in the Months Table. If it exists it should ask the User wheter to overwrite or not. If the User clicks on OK it should delete one record from Months Table if the User clicks no, nothing should happen.However it doesn't delete the record, when I click on OK.

Code:

Public Sub IMPORT_Click()
Dim filelocation As Variant
Dim f As Object
Dim Message As String, Title As String, Default As String
Dim sql As String
Dim MsgReply As Integer

[code]....

View 1 Replies View Related

Modules & VBA :: Viewing Output Of SQL Statements

Feb 27, 2015

The following SQL statements run with no errors, but I can't see the output of the SQL statements. What is wrong with my "Debug.Print" or "rs" statement ? I would like to see the results. The SQL statements works when I save them to a query.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Rem Dim intResult As Integer
Dim strSQL As String
Set db = CurrentDb

[Code] ....

View 4 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

Modules & VBA :: Get Label Name Into Procedure?

Apr 28, 2014

I have a form with about 100 labels and would like something to happen when I mouseover. So I have a following code:

Code:
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = vbBlue
End Sub

[Code]....

View 7 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

Modules & VBA :: Combine OR Statements In Junction With AND Statement

Aug 20, 2013

How do I combined multiple OR statements in conjunction with an AND statement as follows:

If [Len(Field1 & "")=0 OR Len(Field2 & "")=0] AND Field 3 = "Something" AND Field 4 = "Something" Then...

I thought there I had to use a | symbol but I am not exactly sure?

View 2 Replies View Related

Modules & VBA :: Easy Way To Write Nested IF THEN ELSE IF Statements

Apr 12, 2015

How do you write complex nested IF THEN ELSE END IF statements..How do you know what IF statement to put first?Then how would you know where to put ELSE, or END IF?Before you start with the VBA, what are the foundations for making it work successfully, know where you are, know where to put END IF etc?

I've seen many times when using VBA people set up an initial foundation for writing code. For example when needing to put something in quotes, they do "" then enter the text in between, so they don't get errors on running (A very simple, crude example I know, but is there a similar basis for nested IFs).

View 6 Replies View Related

Modules & VBA :: Table Relationships And Select Statements

May 8, 2015

I have coded a select statement that uses multiple tables for information used to populate a report. It returns the correct information, sort of, but it doesn't recognize the already existing table relationships so I get dupicate records. Is there a way to run the code so that it recognizes the table relationships?

View 1 Replies View Related

Modules & VBA :: Returning A Value From Stored Procedure

May 11, 2015

I'm having an issue getting a return value from a stored procedure that I'm calling from VBA. This is what I have at the moment:

Code:
Dim strDate As String
Dim strWOStatus As String
Dim CurrentConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim ParamReturn As ADODB.Parameter

[Code] .....

The problem I am having is this error:
Error: 424
Description: Object Required

The line of code it errors on is:

Code:
Set .Parameters("@PartsUSedMTD").Value = ParamReturn

And the value of ParamReturn is always Null after it hits the line before it.

So it seems like it's not really creating the parameter variable SQL Server needs to run

View 4 Replies View Related

Modules & VBA :: Access Not Responding After Procedure

Mar 21, 2014

This is a real conundrum. The following procedure works well the first time through but on subsequent times the database just goes into "Not Responding" mode and has to be restarted. I have tried putting delays in but with little success.

The idea of the procedure is to rename a query, "Daily Logs" to include a specific date "TransDate" so that when the query is sent via Outlook the Excel file name appears for example as Daily Logs 21-03-14.

DoCmd.CopyObject "", "Daily Logs " & Format(Me![TransDate], "dd-mm-yy"), acQuery, "Daily Logs"
DoCmd.SendObject acQuery, "Daily Logs " & Format(Me![TransDate], "dd-mm-yy"), "Excel97-Excel2003Workbook(*.xls)", "someone@dorsetglidingclub.co.uk", "", "", "Daily Logs " & Format([TransDate], "dd-mm-yy"), "", True, ""
DoCmd.DeleteObject acQuery, "Daily Logs " & Format(Me![TransDate], "dd-mm-yy")

This procedure might seem clumsy but was the only way I could think of the achieve the objective.

View 10 Replies View Related

Modules & VBA :: Determining New Month And Run A Procedure

Aug 6, 2013

I've been stumped for the past couple of days trying to discern a method for a form to determine that it's a new month and run a procedure and only run it on month change.

My initial thought is:

Open recordset
move to the last record
compare the month in a date field within the last record to the current month
and run the procedure if the month is different.

I can't get this to work however and I'm not sure what I'm doing wrong. To be honest I typically fumble my way through VBA when it comes to opening recordsets. Here's what I got:

Code:
Dim rs As DAO.Recordset
Dim db as CurrentDB
Dim strSQL As String
Set rs = CurrentDB.OpenRecordset("FlightLog")
strSQL = SELECT [txtDate] FROM [FlightLog]

[Code] ....

txtReqNumb and txtFltNumb are the values to be reset at the beginning of each month.

Am I on the right track and just have the VBA wrong?

View 4 Replies View Related

Modules & VBA :: How To Call Up Another Event Procedure

Aug 15, 2015

I have 3 event procedure with 3 buttons to make them run.I would like to create another button that can run all procedures togehter. if I copy one of the procedures how do I tell it to run the other 2.

View 2 Replies View Related

Modules & VBA :: Event Procedure On Selection

Jun 27, 2014

I have a form with a field called duration.

The user selects AM,PM or All Day from a list

If the user chooses All Day I want to create a duplicate record

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

However I would like the duration in the first record to be AM and the Second record to be PM

So something like Iif [Duration], "All Day" run procedure.

Else IIF do nothing.

View 2 Replies View Related

Modules & VBA :: Passing Combo Box Control To Procedure

Nov 21, 2013

On my form I have a combo box where the user can select the sex of a person. I had set the row source of the combo to a table, tblSex and this works fine. Now I want to programatically add the table entries ( simply male or female) to the row source, having set the combobox to value list. I cant see how to pass the combobox and tablename parameters and I am getting an error on form load "The expression you entered as the event property setting produced the following error: UserDefined type not defined" The calling procedure from frmPeople is

Code:
'---------------------------------------------------------------------------------------
' Procedure : Form_Load
' Author : Administrator
' Date : 21/11/2013

[Code].....

I think the way the parameters combobox and tablename are passed is incorrect. I want to write a robust procedure which I can use for each of the comboboxes on my form.

View 7 Replies View Related







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