Select Query Based On A User Choice
Nov 13, 2006
Hi,
I would like to run a simple select query, where the CRITERIA is based on the user choice.
I have a form with a combo box, with a few choices, and a button that will trigger a macro with one query for now. I can store the choice in to a variable e.g. "town", using Microsoft VB code.
How can I transfer the variable to the CRITERIA field in the query, so whenever I chose a specific "town", my query will select the records for that specific town.
I want to use one query, and I don't want to have to "hard type the criteria in to the cells' query", but I would like to use a variable that can change and will be read it from the user choice through combo box.
If I am not clear enough, please let me know.
Thank you!
View Replies
ADVERTISEMENT
May 1, 2013
Is it possible to run a basic select query to pull records based on multiple strings entered by a user?
I have a query with field criteria - Like '*' & [Type In MMDBID:-] & '*'
This allows the user to input one MMDBID and the records are retrieved from the db.
I can also use the OR statement in the same field criteria "AB123" OR "BC123", and all records based on those values are pulled back.
But I cannot get the user to input multiple values and I tried amending the SQL string based on the OR criteria above
SQL statement (Like) is below :
SELECT tblFund.MMDBID, tblFund.[Investment Name], tblCodesLive.[IOE Code], tblCodesLive.[Uptix Code], tblFund.[Red Payment Deadline]
FROM (tblFund INNER JOIN tblCodesLive ON tblFund.MMDBID = tblCodesLive.MMDBID) INNER JOIN tblContact ON (tblFund.MMDBID = tblContact.MMDBID) AND (tblCodesLive.MMDBID = tblContact.MMDBID)
WHERE (((tblFund.MMDBID) Like '*' & [Type In MMDBID:-] & '*') AND ((tblFund.Editing)=False) AND ((tblFund.Closed_Fund)=False));
View 10 Replies
View Related
Jan 10, 2014
I am trying to get two different fields to autopopulate when I select a choice from a combo-box on my form.
I have a form called IncomeRcvdFrom, which takes its fields from the table "IncomeRcvd"
In the form, I have three fields that need to relate to each other and auto populate.
The first field is called "IncmType", which comes from a different table called "CategoriesList". There is another field called "IncmDescr" which also comes from the same table. The third field, called "Category" is a list box in that table that comes from another table called "CatType".
All three of these fields also are list boxes in the table "IncomeRcvd", where the source of these fields come from the "CategoriesList" and the "CatType" tables.
What I am trying to accomplish is so when someone selects an Account, or "IncmType", it auto populates the "IncmDescr" field, as well as the "CatType" field on the form.
So far, I have gotten the Account or IncmType and the IncmDescr fields to autopopulate each other, but the Category field either says "Name?", or I get the "type mismatch expression" error message. I also accidentally got the field to work one time, but it would only display the ID Key field and not the actual wording in the rows (i.e. Misc. Payment, Royalty, Rebilling, etc.)
I have checked my relationships, my control sources, and still can't get it to work.
View 7 Replies
View Related
Jun 29, 2005
Hi all,
I have a main form containing client details (tbl_Client) and a sub form containing notes (tbl_notes). tbl_Notes contains a foreign key field (Client_ID) which is obviously the primary key in tbl_Client.
The client is chosen on the main form using a combo box where the user selects the clients name. the id is not visable to the user. How can i get it so that the id (Client_ID) of the selected user is inserted into the Client_ID field of tbl_notes.
Thanks
View 6 Replies
View Related
Oct 20, 2005
Hi
I have been searching this forum for 3 hours for a solution, some come close others are pure gobble de gook to me.
I have on a form 1 combobox where a name is chosen, from that choice I would like the address, suburb, state etc automatically placed intheir relevant fields.
I have tried =DLookUp("[PropertyAddress]","tblProperty","[Property]") in the address textbox which will only bring up the first recod's address from the table, if I change the name in the combobox the address doesn't change.
What am I doing wrong, I have designing databases in Access for a total of 7 days now and have been going fairly well with some tips and code snippets from this forum but this has got me stumped.
Cheers
optidisk
View 2 Replies
View Related
Feb 27, 2014
I am trying to show an image on a form based on a user choice from a drop down box. For example, the user needs to choose a priority for a task. If the user chooses "Immediate" I want an image of an exclamation point to show up to draw attention that this is important.
View 2 Replies
View Related
Mar 8, 2006
Per the instructions detailed here...
http://www.fontstuff.com/access/acctut08.htm
...I created a parameter query in the form of a drop down box that, once an
option is selected, should display a form with a number of fields pre-filled
from a record chosen by the drop-down selection.
The drop down has a command button with the following code in the Onclick
event:
Private Sub cmdCreateReport_Click()
DoCmd.OpenQuery "qryUIRFollowUp", acViewNormal, acEdit
DoCmd.Close acForm, "frmOpenUIRLookUp"
As it now stands when I click the button I get the form but none of the
selected data is filled in. The fields are blank.
What code to I need to add to the above to make the form hold the data
selected from the drop down?
Thanks,
David
View 12 Replies
View Related
May 15, 2013
I want to create a form where by the user can select the fields he requires and the table is created.
Example: I have a table of subjects like maths, english, french, chemistry etc,
The user can choose what subjects are available in that particular school and therefore a table is created based on the chosen subjects.
Is there any way it can be done even with vba?
View 4 Replies
View Related
Oct 10, 2006
I want to be able to have multiple parameter queries, but the user needs to have the option of entering a parameter or not limiting the output at all. How do I let the user choose "all", or what do they type in so that nothing is excluded?
View 14 Replies
View Related
Sep 19, 2014
I have a Table with 57 fields. I would like to display this table in a form as a subform, but only certain fields depending on what selection is made in a combo box.
For instance, if the user selects "Missing Information" in the Combo Box, then the form will show a few standard fields such as ID, Market, Sales Manager, and then some specific ones such as date missing information requested and date missing information received.
If the user selects another option, again the standard fields will remain plus a few different ones.
I have done much searching on this and feel like I am so close but so far. I have looked into controlling the record source of the subform, columhidden =false and a multitude of others. All of which may or in fact probably do work in this situation but I can't seem to put it all together.
View 4 Replies
View Related
Jun 3, 2014
In my database I have a table that keeps track of a package of items. The package is assigned a package type (counter display, end cap, half pallet, full pallet for example). The record of the association of the package and it's type is held in the main table.
Each of these package types is either a case or a pallet (counter display and end cap are cases and half and full pallets are pallets) This relationship is kept in another table (we will call it description table).
Now, based on the type of package and therefore it being a case or pallet a UPC and a GTIN number are assigned. The GTIN number is different if it is a case or is a pallet. I have a table that stores all of the UPC and GTIN numbers available in 3 columns, one for UPC, one for GTIN Case and one for GTIN Pallet (the UPC is a standard 12 digit and the GTINs are 14 digit -with the first 2 different to designate pallet or case. and all are based on the check digit formula necessary)
The user assigns the UPC and correct GTIN number by clicking a button which applies the next available UPC code to the package and determines if the description of the type (case or pallet) and inserts correct GTIN number into that field. I actually have all of this functioning correctly.
Now the problem. If a user changes the package type, and therefore changes the description, I need to add code to the update event of the combo box that gives the choices for package type that does the following:
Check to see if the original package type was a case or pallet (it's description) and if by changing the package type it is now changed to the other, update the record in the main table to the correct GTIN number based on the existing UPC Code.
OR as I write this, maybe the code could simply update the main table with the correct GTIN code based on the new description and the existing UPC code. This was I would not need to check for a change just do the update every time.
View 14 Replies
View Related
Jun 28, 2006
I have Access2003 and a problem creating a simple method of constructing a union query.
I am using a commercial paradox databse that has a habit of creating a new table every time a certain action is performed. There is currently a set of 160 tables with identical fields. The database allows me to view data in these tables individually. I would like to pull the information together, from between 20 and 30 specific tables at any one time, and view the data in one table.
I have linked the tables in a an access database and would go about viewing the data by creating a union query containing each of the tables of interest. Then appending the info in these tables to a new table.
Unfortunately manually adjusting the SQL expression is a bit cumbersome to say the least I am wondering if it possible to select the tables of interest from a List Box on a simple form and have those selected inserted into the union query ?
Alternatively, the table names are actually a field within a different table. Another field within this table actually determines whether they will be of interest. So ideally I could query that table to tell me which tables need to appear in the union query. Again I would like the union query generated automatically as a result of that query.
I am confident, perhaps without good reason , that this must be possible ....
any help much appreciated.
View 14 Replies
View Related
Jun 28, 2007
Hi,
I am trying to write a query that looks at a set of parts that are assigned to the same "Asset" number, and takes the sum of all prices for that collection of parts.
I have the query set up to do this without any problem. Where I am stuck is that in the table containing the details of parts, there are three possible prices. What I need it to do is take price c if there is no value in prices b or a, price b if there is no price in price a (otherwise take price a).
I have tried this using the criteria ="price a" = 0 AND "price b" = 0 (for price c)
and ="price a" = 0 (for price b criteria). When I run the query I get a "Data type mismatch in query expression" error.
Can anyone advise?
Thanks,
Ryan
View 1 Replies
View Related
Feb 20, 2006
Hi all,
I have a query which populates a form called EditPatientFrm, which asks the user to enter the patient UniqueID in order to pull up the record they want to edit from the TblPatient. However, I want the user to now be able to input just one of three criteria in order to pull up the record to be edited:
UniqueID
ChartNumber
PatientLastName and PatientFirstName (two fields)
since they may not have the UniqueID readily available to them.
Can anyone show me how to do this? I have tried to find answer to this one under queries and forms- no avail. Sure it's a simple thing...
thanks!
vrpres
View 1 Replies
View Related
Oct 6, 2006
Good Afternoon Everybody,
Apologies for imposing on you all but I was wondering whether or not you could help me out??
Would you be so kind as to kind as to show me a practical example of how to incorporate a facility into my attached Database which serves to select an equal ratio of my field “SectionHeadings” such that out of the 30 “random” questions that it currently generates it will provides me on completion with the following:
5 From Set1
5 From Set2
5 From Set 3 …..etc etc
It currently generates the 30 questions that I need without a problem; however it routinely selects any number of one particular type, sometimes more from one subject and less of another.
All subjects headings are of equal importance to me and as a consequence would be very grateful if you could look at what I’ve already done and show me what needs to be done in order to achieve my aim.
I hope my request is possible - Any help you could give me would be very much appreciated. Thank you very much.
Best Regards
CarolW
View 5 Replies
View Related
Jun 13, 2006
Hi,
I have a query that I would like to run from a form. I have created the button and the query, but want to add in a clause that will use the user selected record / field as the criteria for the query when its run.
Got any examples of code I could have a play with
I am struggling here so need any help I can get!!
Cheers
Paul
View 1 Replies
View Related
Sep 10, 2013
I have a database table in which I'm trying to pull sales data and generate sales reports from. The problem I face is that the sales data is recorded into a table with this structure:
Year | Customer | Sales_Month_1 | Sales_Month_2 | Sales_Month_3
Rather than having a single field "Month" in which I could set criteria or prompt the user to select a month to derive sales data from, I need to write a query that through user input (or through some code within the query) the right field will be selected. An example of this would be generating a report for the 1st month of the year, obviously.
View 1 Replies
View Related
Nov 3, 2005
Ok this might be basic stuff i'm a bit dumb
I have a query showing lots of records of equipment that is in different rooms. I would like to have a form where the user can bash in a room number and all the records from the query that have that room number in it pop up.
Please help the dumb
View 3 Replies
View Related
Dec 27, 2006
I am trying to create a query that capture all the possible choice of a fields and do some math on them. let me make it clearer.
I have two fields that i need to create a query from forecast type(backup, hardcore) and win percent(76 to 100, 50 to 75, 26 to 49 and 0 to 25).
Forecast type is a drop down that has the following choice hardcore, backup or could be null. Win percent is just a number fields holds value between 0 and 100. One of the criteria for the range of number is when either backup or hardcore is null.i need them to line up as rows or columns so they either look like this
row view
Hardcore
Backup
76 - 100
50 - 75
26 - 49
0 - 25
column view
[Hardcore] [Backup] [76-100] [50-75] [26-49] [0-25]
I am currently using six queries to get the values for each group then joining them to get the final results. the problem with this is the values wont come out correctly. I know there is an easier solution to what i am doing right now.
I need some guidance and help to approach this issue. This will be use in a report so hopefully this provide more alternative to solve this problem.
thanks in advance
View 1 Replies
View Related
Jan 9, 2014
I have a form which lets the user enter a contract ID and then a combo box that has a list of reports which run against whichever ID is entered.
What I want to know if I put the ID's in a table if theres a way to allow the user to select multiple ID's in one go and run the report against them the range rather than 1 at time?
I'm thinking about utilising the check/tick boxes would this be possible? or another way?
I'm using 2003 and have some VBA ability.
View 5 Replies
View Related
May 17, 2013
I have a form that request information from the user (StartDate, StartTime, EndDate and EndTime) the problem is that it's not working. The only way I can get any data to show is when I remove the StartTime and EndTime. Only then will it pull the items from the StartDate and EndDate.
Here is what I have as my criteria: Between [Forms]![OpPROD_ALL]![StartTime] And [Forms]![ OpPROD_ALL]![EndTime] And Between [Forms]![ OpPROD_ALL]![StartDate] And [Forms]![ OpPROD_ALL]![EndDate]
The users will be able to request a report based on a start and end date along with a start time and end time.
Side note: this is to pull date for 3rd shift (Example) 4/14/2013 10:00PM - 4/15/2013 10PM
View 1 Replies
View Related
Aug 17, 2007
Query
SELECT s.contracttypename, sum(s.sumrtr*v.pct) AS [predicted $]
FROM sumrtr AS s, varcurve1 AS v
WHERE s.mdiff=v.monthodr and s.contracttypename=v.contracttypename
GROUP BY s.contracttypename;
I have varcurve1 varcurve2 varcurve3....
I want to provide a mean (interface?) for user to choose varcurve1 varcurve2 varcurve3 to run above query.
for eample if user choose varcurve1
the query will run
SELECT s.contracttypename, sum(s.sumrtr*v.pct) AS [predicted $]
FROM sumrtr AS s, varcurve1 AS v
WHERE s.mdiff=v.monthodr and s.contracttypename=v.contracttypename
GROUP BY s.contracttypename;
if user choose varcurve2
the query will run
SELECT s.contracttypename, sum(s.sumrtr*v.pct) AS [predicted $]
FROM sumrtr AS s, varcurve2 AS v
WHERE s.mdiff=v.monthodr and s.contracttypename=v.contracttypename
GROUP BY s.contracttypename;
is there a way to do that?
Thanks
View 1 Replies
View Related
Jan 15, 2014
I have three check boxes in my form and i want the user to select any one of the check box, if not, i want to display an error msg? How to do it?
View 2 Replies
View Related
May 19, 2006
Hello everyone,
I've made a form where the user can fill in a field ID... and than by clicking on a button another form will be opened with the data of that person (with that ID that's filled in). But if the user fill in an ID that is not currently in the database, there will be also shown another form, but than with no data.. Now I want that if the ID is not known, to display a message or something (like "this ID is not known, try again") and not to open the form..
I've used the following code under the button:
Private Sub openenFormulier_Click()
On Error GoTo Err_openenFormulier_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Onderzoek"
stLinkCriteria = "[Qr_Ant_PG.ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openenFormulier_Click:
Exit Sub
Err_openenFormulier_Click:
MsgBox Err.Description
Resume Exit_openenFormulier_Click
End Sub
Hopefully someone can help me!
Thanks,
Ankie
View 2 Replies
View Related
Aug 22, 2013
How to proceed and what is the "accepted" version of events.I have created a report, a dynamic method statement actually, and want my user to be able select some data to appear in the report. Report is rptMS01, it is fed from a query and has some fields to automatically populate [Company], [Site], [Postcode] etc. All of the static text is in CanGrow textboxes to sidestep the report height limit. The report is opened by a button on a form which uses a macro to open only for the current site. All OK so far.
My boss would like a section/text box/subreport to select the personnel involved in each method statement and this to appear on the report. So, on clicking the button on the form which would usually open the report directly, some kind of intermediary selection form opens instead with a list of all personnel. User can then select which personnel to involve and on clicking OK this appears in the designated box on the report. A CanGrow/Shrink textbox would be ideal!
Do I need to include this in the current query which feeds the report? I know a listbox can have multiple selections but how would I reference this? How do I keep the other fields as well? Should I create a table with the personnel list?...
View 2 Replies
View Related
Aug 7, 2013
I'm trying do a Select Case on a form control where the user is prompted for information depending on the value in the control.
Here's a generic example:
If field1 = "Vegatable" then
Select 1 for Brocolli
Select 2 for Lettuce
Select 3 for tomato
If field1 = "Fruit" then
select 1 for "Banana"
select 2 for "Apple"
select 3 for "Peach"
View 9 Replies
View Related