Microsoft Access Form To Query for Multi Value Field - ms-access

I am trying to write an Microsoft Access query from a form with a multi value field being the criteria. The field I am trying to use is called Population and the field is represented in my database as a List Box that allows multiple values and it is in the Building table. The values it allows are the following:
"Singles";"Familes";"Families with Children";"Youth/Young Adults";"Veterans";
The form that I am creating is called HousingSearch.
I am trying to create a form which uses this field, so someone could use the list box and check off the values they want and click on the button which would open a query. I know having done this with single value fields the criteria in the query looks something like
[forms]![HousingSearch]![Building]![Population]
but if you try the same thing for a multi value field nothing is returned for the query. Any help would be appreciated.

From the information you have provided it seems that the phrase [Forms]![HousingSearch]![Building]![Population] are combining a request that starts with a form and then jumps to a table.
You are asking access to find data in a form but the information you're most likely trying to access is in a table. I don't quite understand what you're end result is but I think that you most likely want to refer to your information this way [Building]![Population]. Referring to your data this way makes access look at the table of [Building] and then into the field of [Population].
It's been a while since you posted, if you haven't cleared things up already I hope this helps.

Related

MS Access-Using value from a form in a calculated field of a table

I have a text box in a form which accepts a date.
I have to use that date in the calculated expression in a field of a table.
Initially I have tried to use this statement in the calculated expression.
[Forms]![Input data form]![Text38]
But it shows that "The expression cannot be used because refers to another table".
How to access the value of the text box?
I think I understand your question. You have a table and you want to use a calculated field in it that references a value in a form.
You will not be able to do it that way. The reason you are getting an error is because the form data only exists when the form is running. If you used that expression in the record source query of the form, you would be ok.
You have a couple of choices depending on what you are trying to do with the data. If you REALLY NEED a calculated field in your table, you can use a form to make an UPDATE to another field in your table; then it is static data and your calculated control can work.
Another option is to have a separate table to store the user input value, then use a VIEW (QUERY in Access terminology) to join the data together and compute the result. Depending on why you are doing it, this is typically the method you want to go with.
If this does not answer your question and you have something more specific, I will try to tailor the answer more.

Access form must be opened twice before combobox values will appear

I have a checklist that is used to perform QC audits. When a reviewer answers a question that requires an exception, a pop-up form will open with the correct exception detail already populated. They then have to provide some further information, which I have set-up in the format of a combobox for a field named 'Condition_Detail.' Some exceptions have only one condition that would be an option in the drop-down whereas others have multiple possible conditions, which is why I don't have that field automatically populated as well. I have a table of possible exceptions and conditions that I have used to create the combobox query. When the database was created, the field the 'Condition_Detail' combobox is dependent on was labeled 'Exception Detail' with a space and in my new table it is called 'Exception_Detail.' I did this because the old data and tables will eventually become irrelevant and I know that it is easier to write code with underscores instead of spaces. I include this information because I had to create a relationship between those two fields in the combobox query so that the database would know they are the same. When I test the database, the form opens as expected with the exceptions already populated (NOT in combobox format - the data appears as text on the form). The issue is that when I select the combobox, it is blank. If I answer the exact same question the same way to trigger the same exception to open in a new record, the combobox does have the correct data in it. I have tried to requery the field both when the form loads and after it updates. It still won't show the combobox values unless I trigger that the form open twice with the same detail populated. An additional piece of information that likely doesn't affect the problem is that the combobox is set-up as three columns so that I can populate two additional fields when the condition detail has been updated. I used the code below to populate that, which works perfectly when I can get the condition detail to appear in the combobox:
Private Sub Condition_Details_Change()
Me.Responsible_Position.Value = Me.Condition_Details.Column(2)
Me.Severity_Description.Value = Me.Condition_Details.Column(3)
End Sub
Thanks in advance for your help!
I figured it out. The relationship I created within the combo box query was unnecessary. The query was searching for values in the table that stored the actual responses/conditions instead of the table that stored the available response options. Because of this, once I had answered the question it knew what to look for, but in the wrong place. Setting up the combo box the usual way with the look-up control value in the form referenced as follows was sufficient to get the combo box to work properly.
Field: Exception_Text
Table: tblPreCloseExceptionDescEnc
Criteria: [Forms]![frmEncompassExceptions].[Form]![Exception Text]

Access filter won't show value list to choose from after 1st filter is set

I'm having a little trouble with the form filter in Access 2007. I'm using the listview in a few forms and the user needs to be able to filter there.
For testing purposes I made a query, which is just based on one table. If I want to set the first filter, it looks like that:
I choose a value and if I want to set another filter (on a different field obviously), there aren't values available to choose from.
This seems to happen only if I use a query (doesn't matter if I use every field, or just a few, based on one table or multiple linked tables). I can of course use the number filter and enter a value manually.
I have another database, where I can use filters when and wherever I want, regardless whether it is a query or a table - I have a list with values to choose from everytime. This means I messed something somewhere up but I have absolutely no clue where.
I'm using Access 2007 (FE/BE), if you need any further details, just ask. Any advice where to start looking is very appreciated!
Well, after playing around for a long while, I figured out what the problem is.
The form recordsource needs to be a query - no sql code, no "select * from query", just the name of a query. Anything else leads to the fact that you are limited in using the filters. I'm not sure if this is a bug or if there is a reason behind this, but that's the way it works in access 2007 - at least for me.
Before I was dynamically adding conditions to my queries which led to a recordsource like "select * from qDeliveries where location = 1". To accomplish this I now just create a temporary query which is the form recordsource instead of just using the sql code.
Hope this helps anyone... :)
Instead of using a query, try this:
File >> Options
Current Database
Scroll down to Filter lookup options
Check ODBC Fields
Close and re-open the file. That should solve the issue.
Create a Separate query and assign to that form. instead of create query within the form. Your problem might get resolved. I did the same way it's working fine for me.

Filter HTML Table Data using Check Boxes?

I am getting Table from a database where I will show the mature records only if a Mature Check Box is checked, so the real thing is that I want to populate data. Is there a simple way to do this?
You need something in your database to identify "Mature Records". Then you just need to modify your query (with something like AND mature=0) if the name/value of the checkbox doesn't appear in the submitted form data.

How to look up values from a table in Access

I have an Access database that is used to store basic info in a table such as first and last name. How would I go about adding the functionality to lookup by last name?
Is there a way to type in the last name and then hit like F12 or something like this? Can someone please point me in the right direction or provide me a link?
SELECT tblPatient.LName AS [Last], tblPatient.FName AS [First]
FROM tblPatient
WHERE (((tblPatient.LName)=[Enter Last Name]));
How do I tie this into my form now?
I'd suggest you create a form, with a textbox 'search' at the top, then either a listbox or subform below to display results.
The listbox record source would be:
SELECT tblPatient.LName, tblPatient.FName
FROM tblPatient
WHERE tblPatient.LName LIKE Forms!myForm!search & '*';
You can either add a Search button, which requeries the listbox, or do the requery via the Change event of the search textbox. The later may be slow if you have a large number of records; if that's the case, you could check that at least 3 (?) characters have been entered before calling the requery.
You just need to create a query in which you put =[?] as the "last name" value.
When you open that view, you'll be asked to type in a lookup value for that field.
Not sure if this is what you are trying to archieve, though...
This is probably a bit overkill for what you want to do, but I assume that you want to perform a search by last name. You should be able to glean the information you need from this article:
Build a search criteria form
http://www.everythingaccess.com/tutorials.asp?ID=Build-a-search-criteria-form
You can create queries in Access if the user you're targeting with the searchability has Access themselves.
From the main Access UI (assuming Access 2007), go to the Create tab and then select the "Query Wizard." Here is an article on the subject.
Otherwise you can create a program and connect to the MDB/ACCDB file running the query programmatically.
Seeing you wish to look up a name and populate the form based on the name selected, I suggest you need a combobox. There is even a wizard for doing exactly what you want. To start, you will need a form bound to a table or query, that is a form with a Record Source.
Add a combobox to your form
Select :
Find a record on my form based on the value I select in my combobox
Select the ID (primary key), Last and First name fields.
Access will display an example, suggesting that you hide the Key (id) column. Accept this.
Choose a name and finish.
There are a few other small things that could be done for neatness, but you will end up with a form that find the record you want. In addition, the combo will autocomplete if you type in a few letter.
If this is an mde, which your subsequent post seems to suggest it is, there is little you can do wuth out the original file. However, you could try opening the database while keeping the shift key held down and see if that allows you to edit. If you cannot get the original and the shift does not work, you could try rescuing the data, if it, too, is stored in this file.