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 Replies
ADVERTISEMENT
Oct 29, 2013
I need a query's field to change to what is selected in a combo box.
Example,
I select product 1 in the combo box on a continuous form, after the update there is a requery. The form now displays the data from product 1.
I have tried putting [forms]![form1]![combo1] into the field box of the query. But this only makes the form display "product 1" in every row, it does not take any data from the table.
View 3 Replies
View Related
Jul 24, 2013
how to make my form controls change size / position as my form is resized / loaded on a computer with a different resolution. Several of the tutorials out there suggest putting code on the "on resize" property of the form. When I looked at the Northwind database to try to mimic their code however, it looks like they must be doing something different as there is no on resize code under the form properties and I was unable to find the code they do use.
View 4 Replies
View Related
Sep 18, 2013
Here is the basic info:
Table has Checkbox column
BusinessDate column (mm/dd/yyyy format)
OrderTotal column (in dollars)
There are others but these are the relevant ones
In the header of the form I have a calculated control box with the following control:
=Sum(Abs(nz([Checkbox],0))*nz([OrderTotal],0)),0)
Which works just fine. The user is presented with a list of all the orders from this table in the form. They check the checkboxes and the control in the header shows the total of the records checked. I need to make 7 of these calculated controls, one for each day of the week. Is this possible? This way the user can see the order totals for each day of the week they have selected.
I tried:
=IIf(Weekday([BusinessDate])=2,Sum(Abs(nz([Pull],0))*nz([OrderTotal],0)),0)
but it still sums up the whole week as the expression holds true.I do not know VB, and I'm sure there is a really neat and easy way to do it in there. I just don't know how.
View 4 Replies
View Related
Feb 12, 2015
I am trying to create a customizable report that would allow the users to choose fields. I have a pretty common code that I found online and adapted it, but it fails on the first SetReportControl function.
The error reads: Run-time error 2465: Application-defined or object-defined error
Could it be something as simple as an incorrect reference? I have checked multiple times, but I am stumped.
Code:
Option Compare Database
Option Explicit
Sub MakeReport()
[Code].....
This is a trial run, in the end I need to be able to open a report, then adjust the Report controls within 1 or more subreports inside the main report. That is a battle for another day.
View 14 Replies
View Related
Sep 15, 2013
I have tab control form with (5) tabs. For this discussion - Tabs 1 through 5. For a blank (new) form sheet tabs 4 & 5 need to be hidden. Based on what is selected via the drop down box (on tab 1) then tabs 4 & 5 may remain hidden or needed to be un-hidden. Example: [DropDown1]
Selection 1: stay hidden
Selection 2: unhide
Selection 3: unhide
Selection 4: stay hidden
Selection 5: unhide
Selection 6: stay hidden
Selection 7: unhide
Selection 8: stay hidden
Selection 9: stay hidden
I think one I figure this out then I can use the 'OnCurrent' event to check the drop down selection as a user selects the a record or scrolls through records.
View 2 Replies
View Related
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
Nov 8, 2013
Is there a way of using a text field value as the heading for query column?
ie change...
Column header: FieldInATable
to
[form1].[field2]: FieldInATable?
View 1 Replies
View Related
Jun 29, 2015
I have a column "CAT" each time that CAT switches between 0 and 1, I would like my query to auto-create a "grouping" and increment the group by 1. What I am looking for is the output as shown below.
ID CAT GROUP
67 0 1
68 0 1
69 0 1
70 1 2
71 1 2
72 0 3
73 0 3
74 0 3
75 0 3
76 1 4
77 1 4
View 6 Replies
View Related
Oct 10, 2014
I have a form with 10 text boxes on it. depending on a Case
I would like to change the special effect and backcolor
select case colour()
case red
Me.Txt1.specialeffect = 1
Me.Txt1.backcolor = RGB(256,256,256,)
case green
etc
I'm trying to write something so that i can apply both these settings to any text box easily.
View 1 Replies
View Related
Dec 19, 2006
I am trying to come up with a simple way for users to query the database and pull back entries relating to the (potentially vague) data they input.
I know how to run a query based upon data input in a form ("=[Forms]![FormName]![FieldName]"), and I know I can do this several times in one query.
However, if one of the fields is blank, the query doesn't return anything.
Is there a way to use only one query, but still allow the user to leave search criteria blank? The only thing I can think of is by using a very convoluted VB script and creating a query for each possible combination of criteria.
It's not an error-checking issue, either, as entering info into all of the fields isn't required.
For reference, the searchable fields are:
Agent Name, Beginning Date, Ending Date (intended for a date range), Request Type, and District Name.
A user could then search for any requests made by an Agent; any requests by an agent within a date range; any requests made by anyone in a date range; ad nauseum.
There are quite a few combinations, there, and I'd rather not create a query for each one (or code the VB conditionals to choose the right one).
I hope I'm clear in what I'm trying to accomplish :o
Thanks in advance!
View 6 Replies
View Related
Jul 2, 2005
Greetings! This forum has been most helpful to a rusty Access user.
I'm creating a student group score entry form, having problems with creating the form I want. Say for example we have the following:
1. Three groups: A,B, and C.
2. Group A has 5 students, Group B has 3, and Group C has 20.
I want a form where I can select group A, and a list of the students will populate and enable me to enter scores for all of them on the same page. This will save time not having to re-enter the information for so many students. If anyone has a clue of what I'm talking about or is willing to lend me aid, I would appreciate it.
Cheers.
View 4 Replies
View Related
Feb 19, 2007
Newbie here. Just trying to make a characteristic (e.g., color) of a button change based upon contents of a form field. Can anyone please adivise. All help is greatly appreciated.
View 3 Replies
View Related
Mar 6, 2008
Just wondering... is this possible.
I have a database with 200 clients. If a user pulls up a record and the customer's insurance has expired, is it possible to change the background color of the form so that this automatically alerts the user that this customer needs to be contacted and the record needs to be updated?
Or are there any other suggestions that may serve the same purpose?
View 1 Replies
View Related
May 30, 2014
I have a form where customer data is entered. one field serves as a criteria for a query. If, for example, A is selected in the form the query uses the criteria "A" in the X field f query. However, if B is selected in the form, the query uses the criteria "B" in Y field of query.
I can easily do this by setting up two queries and having criteria A run in X field of query and similarly for B. However, it seems as if there should be a way for me to have one query and simply use the criteria in a different field.So, is there VBA that will update a given query's SQL to use one criteria in one case and another critiera in another case?
View 1 Replies
View Related
Jun 21, 2015
I have been looking some information on changing image based on form combo box selection on form.
I manage to do case by case but i need it in a simple code because their will be many employees just to avoid adding case by case code for each one.
Private Sub Emp_IDCombo_AfterUpdate()
Select Case Emp_IDCombo.Value
Case "AM-001"
Imageholder.Picture = "C:UsersAMGDesktopam-001.jpg"
Case "AM-002"
Imageholder.Picture = "C:UsersAMGOne DocumentsHR & Admin DatabaseEmployee Picturesam-002.jpg"
End Select
I have employees table where all images location is saved in text field and i have a combo box on form which is employee id.
Tables relationship
Employees_table [PK] to Contracts_table [FK] via field name {emp_ID}
Fields Name
Combo Box name on form Emp_IDCombo and row source is SELECT Employees_table.Emp_ID, Employees_table.EmployeeName, Employees_table.Emp_Pics FROM Employees_table;
Text field is located in employees_table called [Emp_Pic] for images location.
View 10 Replies
View Related
Jun 12, 2014
I have two combo boxes in the form header and command buttons in the form detail. The combos allow the user to select either a customer or a prospect, then the command buttons open forms that only show records pertaining to the customer or prospect selected. Combos are "4Custcbo" and "4Proscbo".
1.How do I change which command buttons are available depending on whether the user has selected a customer or a prospect? Do I use two different subforms or is there a better way?
2.How do I hide the other combo box once the user has selected either a customer or a prospect?
View 3 Replies
View Related
Nov 12, 2014
I have a little "y2k issue".
My DB has many (!) forms that are based on Crosstabs queries. The headers are years, and therefore my formfields has controlsources like 2014, 2015 and so on.
Example:
The table it comes from looks something like this:
tblProject
Project: Myproject
Value: 1000
EndYear: 2014
The crosstab then takes the EndYear as a coloumn header. Then my forms use these fields, now named 2014, 2015, 2016 .... and give me a nice looking table showing the accumulated "end" for multiple projects.
The problem is when the year changes after 31/12, all fields must manually be changed. This means I have to manually change 2014 to 2015, 2015 to 2016 and so on in all of my formsfields controllsource.
I have played around to find a way to change the source of the field, and hoped I could say something like =year(now()) and for the next year say =year(now())+1 but this only returns that year as a value, and not as a controlsource...
The query functions nicely (ive changed the system time, and it has no issues with this structure), but the forms source is still in the previous year, and returns and error (of course).
When the year changes past new years eve, so will the headers (fieldname) change... but how to make the form change fieldsource?
View 3 Replies
View Related
Mar 20, 2013
I have a report that gets its data from a query. I need the query to run before the report based on criteria based from two combo boxes on a form.
View 3 Replies
View Related
Apr 11, 2014
I have a subform that displays doubles in a textbox as fixed with 4 decimal places as default. I have been trying to change the number of decimal places based on the value in a textbox on the main form. I have tried this:
Code:
Forms![Main Form]![Holder_subform].Form![Final PCT].[DecimalPlaces] = CByte(Forms![Main Form].Numdecs)
where [Final PCT] is the textbox on the subform containing the decimal number and Numdecs is the textbox on the main form containing the number of decimals I want to use. I want to implement this Form_Current sub.
View 2 Replies
View Related
Mar 24, 2014
I have created a cross tab to extract pipeline and sales for Q1 2014, Q2 2014, Q3 2014 & Q4 2014... the user can select the quater from a multivalued text box...
Now for the final output, have created another query which pull the above four quarter in each column from the cross tab...now the problem arises when i change the quarter to Q2 2014, Q3 2014, Q4 2014 & Q1 2014..it gives an error "Microsoft office Access database does not recognizes "Query name" as a valid field name or expression".
The error is because the second layer of query does not identifies Q1 2014.
How do i make access change the column automatically when the Q1 changes to Q2...
View 1 Replies
View Related
Apr 22, 2014
I am using Access 2010. I wish to show or hide controls based on the value in the combobox. The combobox is bound with the data type Yes/No. If Yes, controls should be visible and if no, they are to be invisible. The database is a linked one. This selection should update all the users' forms.
View 2 Replies
View Related
Aug 3, 2015
I'm using I have a secondary control being populated by an entry from another control. I was able to find the code I needed to do this using a combo box here in this forum.
me.txtDependent=me.cboPrimary.column(#)
(specifics changed to protect my company's paranoid view of privacy)
the code itself was showing up in the secondary control instead of any value. I found though that moving the code from the On Change event for the primary control to the On Current event for the form itself everything is working beautifully.
However, I have a different task now that I need to be able to accomplish with the same two tables but in the opposite direction. I suspect that I'm going to need to create a second set of controls and maybe even a second relationship or table to do this. To use a set of specifics that I think will get this point across, if I had a master table which includes a field for "City" and a secondary table, CityState, which contains both "City" and "State", and two controls, a combo box cboCityState to look up the specific City and a text box, txtState to display the State, putting the following code in the City combo box's On Change event populates a text box with the State when the specific City is selected, or putting it in the form's On Current event will be sure that State shows up in all the copies of a form when the form is used in a search and the City is not changed :
me.txtState=me.cboCityState.column(2)
What I need to do now is to set up a control which allows me to type in the State and have the results show all records that include that State.
I'm using this in a Filter by Form environment. I know the objections to this method and the benefits to creating a dedicated search form, but this method appears to be working well in all other ways for us for now. I have several situations within this form where I have one control showing up at the initial load of the form and at the beginning of the filtering process, allowing selection of multiple values from a long list of values in a list box, for instance, (using the On Filter event) and other controls showing up as a result of the filtering process, to display the selected criteria only, for instance (using the On Apply Filter event), so I'm aware of how to make this work if that's required. I'm thinking I may need to create a second control, something like txtStateInput, to accept the State search criteria and another, something like txtCityResults, to show the cities that are part of the resultant records.
View 5 Replies
View Related
Oct 16, 2013
I have frmIncident that has a 2-column combo box (cmbIncidentType). Column (0) is IncidentType, Column (1) is YES/NO. This combo box feeds from a Query and currently has about 15 "types" of which 4 have a "Yes" tied to them, then rest "No".There are situated on a TabControl (tabIncident) with 5 sheet tabs. If the Incident Type selected in the Combo Box has a corresponding "Yes" in Column (1) then all 5 sheet tabs need to be visible. If it is "No", then only three of the five are visible. Here it he current code I am using for the AfterUpdate event on the combo box:
Private Sub cmbIncidentType1_AfterUpdate()
If Me.cmbIncidentType1.Column(1) = "Yes" Then
pgEmerIncidentRpt.visible = True
pgNarrClose.visible = True
Else
[code]...
When I open the form is will set the proper sheet tabs that need to be visible, however once I cycle to the next record, or select a different Incident Type, even one with a "YES' in column (1), it will only show the (3) sheet tabs. I can never get it to show all 5.
In the code, the only (2) sheet tabs that need to visible = true or visible = false are shown, starting with "pg".
View 3 Replies
View Related
Mar 31, 2014
I have a form that currently uses a "catch all" table for listing available equipment to choose from for an equipment field. I call it tblEquipment. What I want to do is to make it so when I type a name in (1 of 35) in one field of the current record, the record source for the equipment field immediately looks at a different table that has equipment available only for that name. To do this I plan on making 35 different tables with limited data originally found in tblEquipment. I would call these tblEquipment1, tblEquipment2, etc. I do not use a sub form, nor do I want to.
So my questions are:
1) can this be done
2)If it can be done, how can I do it?
View 3 Replies
View Related
Mar 6, 2007
Hey all,
I'm new to Microsoft Access but I'm not new to programming. What I want to do is when the combo box triggers and On Change event, do the following:
SELECT user_email FROM user WHERE user_first LIKE '[COMBO BOX CHOICE]'
Then set the value of that query to the textbox called "reportedEmail". I know this is easy, but I can't seem to find a decent tutorial on it anywhere.
Suggestions?
Thanks,
- MT
View 1 Replies
View Related