Multiple Queries Need For Different Controls

Aug 11, 2014

I've constructed a trivia database that consists of trivia questions that are classified into different categories. The DB also keeps track of which questions were used at which establishment. I am designing a form that will generate multiple rounds of trivia based on user criteria.

As seen here the user can specify the number of rounds and questions per round. Maximum number of rounds is 8 - the tab visibility is changed AfterUpdate of the number of rounds field.I have queries set up that do what I need for a single round - they choose random questions based on category, subcategory, difficulty and if they haven't been used at that client's before.

how to deal with multiple rounds without it becoming a headache. My tab layout has controls txtCategory1, txtSubCategory1, txtDifficulty1, txtType1, txtCategory2, and so on. Currently the queries use the values in the controls for Round 1. I would have to make eight copies of these queries (one copy for each round) in order to generate each round based on specific criteria, which would make a ton of queries. The other option is to use SQL statements in VBA, but this method doesn't like the [Forms]![frmCreateTriviaNight]![cboCategory1] in the code - I have to concatenate the names of the variables in and the code would be a mess.

View Replies


ADVERTISEMENT

If Statement With Multiple Controls

Jul 14, 2006

Hello,

I have a form with multiple controls (textboxes) named:
Father
Mother
Child1
Child2

On the form there are also two checkboxes (check1 and check2).

I am using the following statement for each control and placed in in the OnCurrent event of my form:
If Not IsNull (Me.Fater) Then
Me.Check1 = "YES" (or -1)
Me.Check2.Value = False
End IF

Is there a way I can write one If statement saying:
If all controls Father, Mather, Child1 and Child2 or at least one of them has data, then Check1 should be selected and check2 emply. If all controls do not have data then ckeck1 should be empty and check2 selected.

Thank you.

View 2 Replies View Related

Multiple Ifs And Null Controls

Jan 22, 2007

Hello, I am reposting a question submitted some time ago to which I did not get much help, hoping for additional advice.

My database has two tables. Table1 and Table2. Table2 is a copy of Table1. Both tables have 50 fields. Data is imported into Table1 once a week. Before importing data I run a delete query which removes all data. Data imported adds records only to the following fields: FNAME, LNAME, SSN. This means that I am left with 47 empty fields.

Users can see data in Table1 using Form1. They will see the FNAME, LNAME and SSN. These fields are locked and cannot be edit or deleted. All the other 47 fields are blank and user can add data to them.

Currently I am using two buttons to:
1) Close the form (with the code Me.Undo, Me. CLose)
2) Run and append query to Table2 and deleting all added data.

I would like to combine these two functions in one button which would:

If no data has been entered in the remaining 40 fields, than close the form.
If data has been entered it should run the following procedure (Append data into Table2):

Dim MyDb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Dim stDocName As String
Dim stLinkCriteria As String

Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("Table1")
stDocName = "MyForm"

stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.SetWarnings False
DoCmd.OpenQuery ("AppendtoTable2")
DoCmd.Close

The problem I am having is declaring all the 47 empty records. Any suggestion or code? Thanks.

View 1 Replies View Related

Firing Event For Multiple Controls

Jan 10, 2006

i have 15 text boxes named Qty1, Qty, Qty3, etc...

and another 15 text boxes named Comment1, Comment2, Comment3, etc...

i'd like to write an AfterUpdate event code that will apply to all of the Qty controls..instead of write 15 individual AfterUpdate events..

is this possible at all?!

View 6 Replies View Related

Create New Record From Multiple Controls

Aug 8, 2007

Hello,

I have two controls on my form that I want to reference in an append query to create a new record. The first is a text box, the second is a combobox that is populated with all of the dates associated with the text box. The selection of a date updates a subform based off of a hidden column (chart ID, an autonumber field based on combinations of record numbers and visit dates) in the same combobox.
I would like the user to be able to enter a new date and create a new record that would contain the next autonumber in association with the new date and the record number from the text box control. I have tried using an append query with the following SQL, but I consistently get errors referring to "type mismatch." Any help would be greatly appreciated; thanks in advance.

Code:Private Sub cboDOVSearchChart_NotInList(NewData As String, Response AsInteger)Dim ans As Variantans = MsgBox("The date you entered was not found. Do you want to add a newdate?", _vbYesNo, "Add New Date?")If ans = vbNo ThenResponse = acDataErrContinueMe.cboDOVSearchChart = NullDoCmd.GoToControl "cboDOVSearchChart"GoTo exit_itEnd If' add dateIf ans = vbYes Then Dim strSQL As String strSQL = "INSERT INTO Patient_Visits ([Medical Record Number], " _ & "[Date of Visit]) " _ & "Values (" & Me.[txtChartMR] & ", " _ & "#" & CDate(NewData) & "#)" 'this line has the arrow on debug CurrentDb.Execute strSQL Me.cboDOVSearchChart.Requery Me.cboDOVSearchChart = NewData Call cboDOVSearchChart_AfterUpdateEnd Ifexit_it:End Sub

View 2 Replies View Related

Modules & VBA :: Set Event Handlers On Multiple Controls

Aug 7, 2013

I am trying to set event handlers on multiple controls in code. This works:

Code:
Me.Controls("txtPosition" & Right(CStr(iLoop + 100), 2)).OnClick = "=UpdateTaskList(" & CStr(iLoop) & ")"

This doesn't:

Code:
Me.Controls("txtPostIt" & Right(CStr(iLoop + 100), 2)).OnGotFocus = "=PostItGotFocusHandler2()"

The second gives an error: "The expression you entered has a function that <databasename> can't find.

I suspect it may be a parameter mismatch, but the normal GotFocus event handler does not take any parameters.

View 2 Replies View Related

Modules & VBA :: Class Event For Multiple Controls On Userform

Mar 5, 2014

Basically I have a class event that works for all controls on any userform.

Its all working fine but I can't add an event to trap the click or mouse move of the userform itself.

Basically so when the cursor moves away from a control the label clears.

User Form Code

Code:
Option Compare Database
Option Explicit
'Define a collection and initialise the commandbutton event class
Private col As New Collection
Private newCmd As New clsEvents

[Code] .....

And here is the class Module

Code:
Option Compare Database
Option Explicit
'catch the event of Commandbuttons
Private WithEvents C0 As SubForm
'Private WithEvents C1 As CheckBox

[Code] ....

View 11 Replies View Related

Forms :: Using Multiple Calendar Controls With Same Control Source?

Feb 26, 2014

On the form I need to give the user the option to select a 'from date' and 'to date' and for this I have put in 2 calender controls which have the same control source(same table column). The problem I am facing is when I select a date from one calendar, the other calendar control automatically populates with the same date and vice versa.

I need to have a functionality where 2 different date can be selected and then when the Search button is clicked, then data within the date ranges should be displayed.

what changes I need to make to acomplish this ? find a screenshot of the form attached.

View 5 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 :: Set Up A Series Of Controls Then Bind To SQL Queries?

Jul 10, 2014

I have about 12 tables in a 2010 database and I want to create a single summary form showing key details of the database. Most of these will be count fields using various subset of the tables e,g. total members, count of new members this year, count of those not attending a meeting etc. More than one table will be represented on the form.How would I set up a series of controls that I then bind to SQL queries? Or is this not the way to do it?

View 8 Replies View Related

Queries :: Change SQL Where Based On Form Controls

Jun 30, 2015

I have a form with a combobox, textbox, a button and a listbox.

Currently the button checks if the textbox is empty and if it is, it runs a SQL query to select data using the combobox value in the where clause, else it selects data using the textbox value in the where clause

I need to be able to type or select values in both controls and use those values in the SQL query as a where.

View 6 Replies View Related

Queries :: Using Controls From Separate Forms As Parameters In Same Query?

Mar 28, 2014

I have 3 forms that all use the same sub form. The 3 main forms show 3 different project types, where the sub form shows what other projects that a company is engaged with. Rather than create 3 different queries for my sub form, i would like to just filter it using criteria that looks at the CompanyID field on my 3 main forms. Currently my criteria is like this:

[Forms]![frmProjects_Detail_IND]![txtcompanyid] Or Like [Forms]![frmProjects_Detail_CSS]![txtcompanyid] Or Like [Forms]![frmProjects_Detail_TAP]![txtcompanyid]

Is there a way to ignore the parameters that are null?

View 3 Replies View Related

Queries :: Adding Rows To Table - Bypass Field Controls

Jan 1, 2015

There is a table with many columns. I want to add many rows to this table. The easiest way is to write a query to do that. But most of the columns have validation criteria, lookup tables, default values, nulls not accepted condition and what not. Where as my new records to be added have only the values in 4 columns and the rest are null. Is there a parameter that can be used to bypass all these controls and add the records? You are going to say "You will destroy the integrity and consistency of the database".

View 1 Replies View Related

Queries :: How To Count Records Based On Multiple Criteria From Multiple Tables

Jan 4, 2014

I need to count records based on multiple criteria from two different tables. I have two tables (i.e. "tblTasks" and "tblTaskHistory"). The tables have a one-to-many relationship based on the "TaskID" field. "tblTasks" has a field called "AssignedTo" and "tblTaskHistory" has a field called "TaskStatus". I need to know how many tasks have been "reopened", the "reopened" status is located in the "TaskStatus" field in "tblTaskHistory". I need this count against a unique listing of employees which can be found in the "AssignedTo" field in "tblTasks".

View 4 Replies View Related

Queries :: Possible To Set Multiple Conditions Across Multiple Tables

Apr 10, 2013

Is it possible to set multiple conditions across multiple tables using OR in a where clause? For instance, can you run where......

(table1 = 'test') or (table2 = pass) or (table2 = "fail) AND (class = 'SQL');

View 1 Replies View Related

Queries :: Put Multiple Records In Multiple Columns

Jul 31, 2013

I have three tables. Risk, Names and RiskAndNamesJunction table. I have the junction table because I have many to many relation (meaning many people can be connected to one risk and many risks can be connected to one people).

The problem is that If I make a query to show the people related to the risks, if there are many people for one risk then it will put the people in different rows. Meaning that for risk 2 I will have three rows, because there are three people connected to this rows. See the attached file!

What I would like to do is to have a query which (in case there are more than one risk owners) puts the second name in another column, the third name in another column and so on. So I will have only one row per risks.

The attached file is a dummy file, so there are only maximum three names per risk. In the real file the maximum is five names per risk. So I am talking about no more then five extra columns. (So I am talking about a query which would put the first finding in the first extra column, then the second item in the second and so on till five. It there is no third or fourth or fifht item then the columns remain blank).

Unfortunately I have to do this because our mother company works with excel and they are sticking to this format in excel.

See the attached file ....

View 2 Replies View Related

Queries :: Running Multiple Queries To 1 Excel File With Different Tabs For Each Query

Jul 18, 2013

I'm using Access 2003 and excel 2003.

We currently manually run 5 different queries then copy and paste this data into 5 separate tabs on 1 workbook, I'm trying to automate some of this process if possible.

I am trying to use the 'transferspreadsheet' action within a macro to run a query and post it into a template excel file, using this code:

Trasfer Type Export
Spreadsheet Type Excel 8-10
Table Name (query Name)
FIle Name (FIle location)
Has field names No
Range Blank
----
This does seem to work and puts the data on a new tab on the specified workbook.

However I have a few questions:

1. Can you specify which query gets put onto which tab in excel? The tabs have different fixed names.

2. Can you specify which Cell the data gets pasted into to? As each tab has a set of headers and titles which need to remain.i.e would need to get query 1 to start in cell A4.

3. How would you expand the above out so that it runs all 5 queries, would you just add in multiple transfer spreadsheet actions in the same macro?

View 1 Replies View Related

Queries :: Method For Combining Crosstab Queries With Same Criteria From Multiple Fields?

Dec 2, 2014

I have 3 cross tab queries that are completely identical with the exception of the field that they pivot. Each field is searching for the same values just in different columns, with the end goal being to get the sum of the values for each pivoted column. I'm wondering rather than having 3 almost identical queries is there a way to use a crosstab to sum the values from each of the three fields rather that having 3 queries which then have to be aggregated in a fourth?

QUERY1

Code:
TRANSFORM
IIf(Count(PT_LEVEL.UNIT) Is Null,0,Count(PT_LEVEL.UNIT)) AS CountOfUNIT
SELECT
PT_LEVEL.INF_YEAR,
PT_LEVEL.INF_MONTH,
PT_LEVEL.UNIT

[code]...

View 2 Replies View Related

Queries :: Combining Data Results From Multiple Queries

Sep 30, 2014

I am working on a report that has some special characteristics.

Let's say I have a list of groups of Vendors in a table, complete with VendorID. I have 3 other tables that use the VendorID: Complaints, Complements, and Terminations.

Each of these tables has a date that the Complaint, Complement, and Termination notice was received.

Every Fiscal Quarter, a report is pulled that looks back over the 4 preceding quarters to determine if a 5% threshold has been crossed by any of the vendor-groups in regards to the amount of Complaints they received.

The equation used for that is : (complaints/vendors_in_group)*100

It is imperative that the information has the current fiscal year and fiscal month (which I am tracking with functions from MS website), and I need to be able to store the information attached to the fiscal year and month.So when a user goes to the form and inputs the desired Fiscal Year and Fiscal Month, the database can display the 4 previous quarters of information...split into Q1, Q2, Q3, and Q4.

What I would like to have happen is to be able to have one table where the information is stored, quarterly, so that it can be retrieved for the report.

Questions:
1. Is it possible to have one line, per VendorID, that has the total number of Complements, Complaints, and Terminations, as well as the threshold percent stored in a table? Right now, I am getting LOTS of duplicates and blank lines when I try to put them all together. It has the right data, but takes about 10 rows per VendorID.

2. It is very important that the total number of Vendors in a group be captured on that quarterly report, so maintaining that number, in the same table, is essential and must be tied to the VendorID.

3. I have looked at Union Queries and Crosstabs, but I just dont know enough about them to make it work.

View 4 Replies View Related

Queries :: Creating A List Based On Multiple Queries

Jun 23, 2015

I have 3 select queries which Im trying to output to a combo - Ive tried a UNION query but I get an error

ODBC-- call failed ODBC Driver SQLBase.....

Firstly is do the results need to match within a union query? I mean they have no relationship what so ever Im just trying to populate this combo with the same results.

Secondly is there a better way to do it? 2 of the select queries query a linked SQL table and the third is a local table. All of the select queries work on their own.

View 2 Replies View Related

Queries :: Access Multiple Queries Run With Date Parameter

Jun 19, 2015

I have 5 queries that I am running. The first query has the date range parameters set in the field area that I need to run and each additional create table query is based off the results of the previous query.

1. Which is better to use to run all of the queries in one simple step? A macro or a form? I am exporting the final table to excel so that I can make some additional adjustments off of it.

2. How would I setup the date range parameters for the first query if I were to use a macro without going into the query itself and updating the date field? I tried setting up a macro to run the queries by using the OpenQuery action for each of the 5 queries, but I cannot figure out how to do the date range.

View 11 Replies View Related

Queries :: Report Or Macro To Run Multiple Queries Using Same Parameters?

Aug 9, 2013

So I run cash flow for a business, and we export data from Oracle and insert it into an access database. I have to run about 25 queries, entering in the same parameters for each. We number each week of the year. So for say the first week in January, I would run the first query and it asks: Beginning Week, I enter in 1, then another paramter value asks me the ending week. I have to enter in these parameters for each of the 25 or so queries, and it becomes quite irritating. Each query has a number of columns, but I am only interested in obtaining the sum of one of the columns, titled Distribution amount. So I am looking for something that will run each of my specified queries, then spit out the total of the distribution column for each in a table like.

Query 1: Total Distribution
Query 2: Total Distribution
etc....

Is there anything that would allow me to do this, with entering in the week parameter once, say week 1 start, week 1 end. and it use those same parameters for each query?

View 1 Replies View Related

Queries :: Option Other Than Multiple Unmatched Queries

Apr 11, 2013

Is there anyway to join 15 queries into 1 (all have the same data from a different source but need merged into 1 large query) rather than doing 12 unmatched queries?

Let's say I have 5 records in the first query, 5 records in the 2nd, and 3 records in the third - I want to end up with 1 query that has 13 records.

View 4 Replies View Related

Query To List Multiple Records In A List From Multiple Queries

Jul 11, 2013

I have a DB where you there's 5 tables all linked together by one project ID

tables below

Project , Staff, Asset, allowances, travel, mark up

What I can do is create a new project, then add records to each of the other tables on what different items I require,

i.e. I create a new project - called project one, in the project table I create a record stating, name, time scale, client and location, then I add different records to each of the other tables on what I require all linked to the same project ID. (probably not explained that too well)

Now I want to create a query that lists all the requirements one after the other this will make it easier to create reports and to calculate costing's.

At the moment I have made 5 different queries listing all the data, then have one report containing 5 sub reports to display the data, no this does work.

View 7 Replies View Related

Queries :: How To Get Sum Of Multiple Queries In Each Column

Oct 1, 2014

How to write the syntax to get the sum of a query in a query builder. I want to get the sum of multiple queries in each column. ie (Query: R1-R7)

View 3 Replies View Related

Multiple Queries

Apr 18, 2006

Help. I am relatively new in working with Queries. I am taking over someone else's database. I would like to do the following" take test results and combine into one query. Here are my variables :q# question, response(numeric),expr (response to text description such as agree, don't know, disagree. ) for questions 1-5(response) are : 1, 2, 3. I use my expr(IIF) to give me my text description: agree, don't know, disagree. Say my 2nd query is questions 6&7 only which response numbers are 1,2 and expr(text desc):Yes or No. My 3rd query is for q# 8,9,10 which are 1, 2, 3 and expr:some, all or none

I would like to accomplish the following:

How do I combine into one big Query

I thought I read somewhere that I could link my query to run one after the other to provide the final result into one table. I hope this is detailed enough


Help:o

Rainy

View 1 Replies View Related







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