Execute Based On Parameter

Jun 8, 2005

Hi,

Based upon the parameter given i want to run different queries
i need to do the below in one query.

PARAMETERS Proj Text( 30 );
If proj="All"
Select * from TbProj
else
Select * from TbProj where Proj_ID=proj;

I want to build an access query like above.
I don't know whether it supports using IF statements.
how to do the above.

Thanks.

View Replies


ADVERTISEMENT

How Do I Re-execute The Query A Subform Is Based On?

May 26, 2006

Because my tables were already large I split them up by environment to speed up data maintenence and retrieval. Thus I have table names which contain the environment as part of the table name (ex: tbl_TEST_MyTable, tbl_PROD_MyTable). Once the user sets the environment they want to use (by clicking on an option button) I update the form's recordsource to the appropriate table. My form has 5 subforms within it.

Even with the split loading the form was taking a long time because some of the queries the subforms are based on are joining tables so that they can be linked (parent/child) to the form. I created indexes to speed up the data access which helped a little but it was still running too slow. So, I attempted to change the subform's queries to only join the necessary data by re-creating the queries each time the user changes the form's current record.

For example, what I had originally was taking too long:

SELECT DISTINCT tb.*, pt.CollId, pt.ProgName, pt.QueryNo
FROM tbl_TEST_SysTables AS tb INNER JOIN tbl_TEST_Plan_Table AS pt
ON tb.Name = pt.TName
ORDER BY tb.Name;

and the parent/child link fields are CollId, ProgName, and QueryNo.

This is the change I made:

SELECT DISTINCT tb.*, pt.CollId, pt.ProgName, pt.QueryNo
FROM tbl_TEST_SysTables AS tb INNER JOIN tbl_TEST_Plan_Table AS pt
ON tb.Name = pt.TName
WHERE pt.CollId = 'BATCH_COLLECTION'
AND pt.ProgName = 'PROGRAM1
AND pt.QueryNo = 123
ORDER BY tb.Name;

where the pt fields are changed dynamically each time the user navigates to the next record in the form. This resulted in much faster access time; however I discovered that the form was always displaying the query that existed before the form was opened. I have not been able to figure out how to get the subforms to display the latest created query.

While debugging I discovered that the form's OnCurrent event was being executed 3 times before the form is opened. I don't know what I'm doing that's causing this.

I also discovered that the subform events are executed before the form's events, so I think that's why the latest query isn't being used. I attempted to requery the subform in the form's OnCurrent and OnOpen event, but to no avail.

View 4 Replies View Related

Chart Based On Form Based Parameter Query

Mar 22, 2006

Hi all,

stuck on this, not sure if it can be resolved....

I have a parameter query for which the parameter is based on a form field entry (i wanted to avoid the dialog box popping up).

No problems with this....however, I want to create a chart based on the same query however, i get the following error message because it does not recognise the query parameter.

Error Message: The Microsoft Jet database engine does not recognise '[Forms]![frmChooseDTDate]!DateOccured' as a valid field name or expression.

Can this be resolved?

Help most appreciated!

regards to all

K

View 2 Replies View Related

Forms :: Parameter Based Query - Filter A Form Based On Another Form

Mar 20, 2013

I have a form which uses a parameter based query to present an individual senior doctor with a list of names for of individual juniors to provide an assessment report on. When the first form opens the user enters their RespondentID.

Once senior has decided which names to comment on I have another form which has the questions to be answered which is opened by clicking a button on the first form.

How can I pass a parameter from the first form to the second so that only the records relevant to that senior doctor are displayed? The underlying table has 60 senior doctors and 20 junior doctors. The senior doctor is identified by the field RespondentID in the first form. I've tried putting a WhereClause in the FormOpen command but I still get a dialogue box asking for the parameter RespondentID when the second form is opened.

View 2 Replies View Related

Parameter Query Based On A ListBox

Jul 1, 2006

I have a listbox on a form and I want to refer to the second column and use this value in a parameter query.

I'm using the syntax

Forms!formname!listboxname.Column(1)

but it doesn't work. I have attached the problem.

View 3 Replies View Related

Queries :: Reference Another Query Based On Date Specified As Parameter

May 16, 2013

Within a query, I'd like to reference another query field based on a date specified as a parameter.

In my query, there are fields for each month: [January],[February], etc.

I have a field titled [Current Month], based on the parameter [As Of Date]. So if when running the query, the parameter pops up and I type 5/6/2013, it knows that the month is May. I know how to return May in the current month field (format([As Of Date],"MMMM"). But how to I return the value that is in the May column?

View 3 Replies View Related

Reports :: Print Report Based On Input Parameter

Jul 2, 2015

I have to print a label quickly every time that the product hit the warehouse. The label has been created as a report linked to the query that will provide the info to the report. In order to make this report printing as quick as possible the idea is to scan the sample id from the product and once the label is printed scan the next sample and an on.

I'm not an expert on VBA but I have created the following scrip but the reports doesn't pop up.

Here is the code:

Dim SampleID As String
SampleID = InputBox("Enter Sample ID")
If SampleID > 0 Then
DoCmd.OpenReport "rptGRM_QuickPrintLabelDymo", acViewPreview, , "[Sample]=" & SampleID
Else
DoCmd.Close
End If
End Sub

View 8 Replies View Related

Modules & VBA :: Export A Report Based On Query Which Has Parameter?

Sep 22, 2014

I'm trying to export a report based on a query which has a parameter.

this parameter has to come from the recordset.

now if i run the procedure it asks me for the parameter.

How do i get it to take the parameter from the recordset?

it should take the column 'Company#' from the recordset

here is what i have now:

Public Function mOutstandingInvoices2()
On Error GoTo mOutstandingInvoices2_Err
Dim rst As Recordset
DoCmd.SetWarnings False
'On Error GoTo BREAKOUT

[code]....

View 10 Replies View Related

Form Based Parameter Query With Multiple Controls Used For One Criteria

Nov 14, 2012

My form-based search mechanism uses controls to set the parameters for the query data source.

I have one field call quantity in stock. I could you a Between and And method to allow the end user to input the stock quantity they want.

HOWEVER, i would love it for the user to first select the Comparison Operator (e.g. > , <, >=, <=) from a combo box and then in an adjacent text box, enter the quantity.

The expression i entered in the query goes something like this.... Forms![frmSearch]![cboRange] & [Forms]![frmSearch]![txtQuantity]

When i try and run this, i get the message "THe expression is too complex to be evaluated".

View 5 Replies View Related

Forms :: Applying Parameter Based Wildcard Search On Subform Filter

Jul 31, 2014

I have a Main form, and a subform which lists client details. On the Main form I have an unbound field. I want to be able to type a word into this unbound field and have it display all company names that have this word in them. ie. I type "Ltd" into the unbound field and it displays all companies with "Ltd" in the title.

I have created a query that does exactly this (Like ("*" & [Enter Word] & "*")), it displays a dialog box and I type in "Ltd" and it displays all relevant companies.

I have tried everything I know to make this work when I use the unbound field on the Main form, but I've had no luck.

View 3 Replies View Related

Queries :: Parameter Query Returning Incorrect Results Based On Checkbox

Jul 31, 2013

I have a parameter query that contains information on a list of people and contains 3 checkboxes: alumni, parent, business

In this query, I am trying to use parameters to filter the results based on these three fields i.e.

true, false, true would return all records where either alumni, business or both are true, and parent can be either true or false.

false, true, false would return all records where only parent is true, and the other fields do not matter.

View 2 Replies View Related

Queries :: Parameter Query Failed Based On Selection From Drop Down List

Feb 23, 2014

When creating a query I have set up a parameter query as instructed (in this case searching for a name) but when I run the query it returns the error 'this expression is typed incorrectly etc.'

I have worked out that this must be due to the fact that the names are not typed in by a front-end user but need to be chosen from a dropdown list (which i have stored in a separate table) - So, the query seems to fail based on that.

View 10 Replies View Related

How To Handle Multiple Null Values Using Form-based Parameter Queries

Nov 19, 2012

i'm creating a search form giving the end user a range of controls to use when filtering/searching data. See the image.But, i think my range search (using the textbox) to put in a lower and upper limit...is preventing this from working. In fact, when i put data into all the controls, no data pops up in my subform.

My query data source can also be seen...showing you how i've handled teh null entries. (i need to put in a null 'handler' for the two textboxes?)

View 2 Replies View Related

Which One Of Them Is Fast To Execute?

Jan 23, 2006

Just had a query in my mind. I have a table master_data with 16 columns. so please tell me which one of the following would less time to execute.

1. select * from master_data;

2. select cust_name from master_data;

From the above example, i am interested to know, does number of parameters selected in the query effect the execution time.

View 2 Replies View Related

Execute Query

Jul 3, 2007

I'v defined an update query as a string in my VBA code.
Then I execute the update query with : CurrentProject.Connection.Execute

however, I want the query out of the code and into the query folder where the other query's are.

How can I execute the query from within the VBA code when I do this ?

View 1 Replies View Related

Execute A Query From ASP

Dec 12, 2004

Can I execute a query I have stored in my Access database by using ASP from a webpage?

Thanks,
Been at the for 3 hours.

View 1 Replies View Related

SQL Execute Failure

Jun 17, 2007

Hi all

I'm stuck on the following SQL statement. It looks OK to me... but there must be something wrong with it because it doesn't execute.

I've tried the runSQL command and I've tried currentproject. connection.execute as well. Both fail to execute... it has to be the SQL string below.

Thanks for any advice.

SQLImportPE = "UPDATE data INNER JOIN data_import ON data.ID = data_import.ID" & _
"SET data.pe1 = data_import.pe1, data.pe2 = data_import.pe2, data.pe3 = data_import.pe3, data.pe4 = data_import.pe4, data.pe5 = data_import.pe5, data.effort_pe = data_import.effort_pe" & _
"WHERE (((data_import.pe1) Is Not Null));"

View 10 Replies View Related

Execute A Form Daily

Dec 11, 2007

Hello again!

Does anyone know if it is possible to execute a form daily?? Like a winows scheduled task or something??

The form I need to run daily basically takes the information from one .txt and keeps it into a table.

Thank you!

View 8 Replies View Related

How To Execute Query From C Drive ?

Sep 27, 2005

Can I keep my queries in the C drive and execute it against tables that are in the LAN network drive ? Right now the queries are also in the netowrk drive. So each time when I refresh the data into C drive, I have to import the queries too.

Is it possible to keep the queries in the C drive and execute against data in the netowrk ? Please let me know.

Thanks in advance.

View 9 Replies View Related

Execute Two Statments In Query

Mar 11, 2008

Is there a way to execute two statements in one query in access? I tried the following but received the following: "Characters found at the end of the SQL statment".

Here is what I have in my qryUpdateRecords file:

"UPDATE dbo_CE, tblCE_Details SET tblCE_Details.LIC_NUMBER = [dbo_CE].[LICENSE_NUM], tblCE_Details.Credit_Hours = [dbo_CE].[CREDIT_HOURS], tblCE_Details.Course_Sponsor = [dbo_CE].[COURSE_SPONSOR], tblCE_Details.Course_Name = [dbo_CE].[COURSE_NAME], tblCE_Details.Auth_Code = [dbo_CE].[AUTH_CODE], tblCE_Details.Category = [dbo_CE].[CATEGORY], tblCE_Details.Course_Date = [dbo_CE].[COURSE_DATE], tblCE_Details.ImportDate = Now() WHERE ([dbo_CE].EXPORT_TIMESTAMP IS NULL ) ; UPDATE dbo_CE SET([dbo_CE].EXPORT_TIMESTAMP = NOW() WHERE ([dbo_CE].EXPORT_TIMESTAMP IS NULL);"


Thanks,
CRhodus

View 3 Replies View Related

Execute Commands From ListBox

Nov 22, 2005

There is one table Name "Menu"

Code:MenuTitle MenuCommand----------------------------------Add Customer docmd.openform "frmAddCust"Print Customer docmd.openReport "rptCust" ,acpreview

Know i want to execute menucommand when i select menuTitle in listBox.
Please Help How can i do this.

Integer

View 1 Replies View Related

Modules & VBA :: How To Execute SQL In Automation

Aug 7, 2015

I'm opening a second database (db2).

Copying the structure of a db2 table to db3.

Populating the table in db3 with a subset of records from db2.

I've gotten as far as opening the db2 and copying the table structure. Can't figure out how to run the query using execute rather than docmd.openquery.

Code:
Dim appAccess As Access.Application
Set appAccess = New Access.Application
appAccess .OpenCurrentDatabase "DbPathString"
'copy the table structure to dbQn, overwrites any previous with same name

[Code] ......

View 4 Replies View Related

Error Message Cannot Execute Command

Mar 3, 2006

I got the error message cannot execute command after we upgraded from Access 97 to Access 2000. There are multiple users connected to one database on Windows 2000. Some people are able to get access, but there is a good chunk of people that get the error message " Cannot execute Command".

What's going on and is there a solution?

View 3 Replies View Related

Can I Execute A Query And Capture Result?

Oct 21, 2005

I have a stored query in my db. The query gets the recordcount of all the items in a table.

In my VBA, rather than code a new db conection, set a recordset etc, I want to execute the query using DoCmd

=======
DoCmd.OpenQuery stDocName, acNormal, acEdit
=======

The above line displays the results of the query.

What I really want is to run the query and store the recordCount in a variable - without displaying the results.

Can this be done?

Thanks all

View 2 Replies View Related

Execute Expression In Query If Not Null

Jun 28, 2006

Can anyone help...

I am writing a query in which, amongst other things, I also want to perform a dateadd calculation.

I have the following

expr:dateadd("d", [lastduration], [lastlandingslot])

This fails to run as the expression is too complicated, I suspect this is because a lot of the records will not have a [lastduration] and its therefore null.
I have ran the code below sucessfully.
expr:dateadd("d", 1,[lastlandingslot])

How can I get this to execute only if the [lastduration] is not null??

Tried to search but network is really slow

View 7 Replies View Related

Query Taking Forever To Execute!

Oct 9, 2006

SELECT FCST.REF_DT AS [Date Forecasted], ACTUAL.REF_DT AS [Date Shipped], FCST.QT AS [Qt Forecasted], ACTUAL.QT AS [Qt Shipped], FCST.PART_NR, FCST.REGION, FCST.TYPE, IIf(FCST.QT=0,'',formatpercent((ACTUAL.QT-FCST.QT)/FCST.QT,2)) AS MPE

FROM TBL_FCST_WKLY AS FCST, TBL_ACTUAL_WKLY AS ACTUAL

WHERE (FCST.TYPE=ACTUAL.TYPE) AND (FCST.REGION=ACTUAL.REGION) AND (FCST.PART_NR=ACTUAL.PART_NR) AND

FCST.REF_DT = (SELECT DISTINCT DATEADD("ww",-LT.LEADTIME,ACTUAL.REF_DT) AS FORECASTED FROM TBL_FCST_WKLY FCST2 INNER JOIN LEADTIME LT ON LT.COMPONENT=FCST2.PART_NR AND LT.REGION=FCST2.REGION WHERE FCST2.PART_NR=FCST.PART_NR AND FCST2.REGION=FCST.REGION) AND

FCST.MONTH_DT = (SELECT DISTINCT DATEADD("ww",LT.LEADTIME,FCST.REF_DT) AS FORECASTED FROM TBL_FCST_WKLY FCST2 INNER JOIN LEADTIME LT ON LT.COMPONENT=FCST2.PART_NR AND LT.REGION=FCST2.REGION WHERE FCST2.PART_NR=FCST.PART_NR AND FCST2.REGION=FCST.REGION);


i am querying two tables TBL_FCST_WKLY which has 29500 records and TBL_ACTUAL_WKLY which has 798222 records.
When i run this query it sites there forever. Is it because i dint optimize my query or is it because the number of records is too much for access? can someone help plz.

thanks

View 9 Replies View Related







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