Thursday, October 2, 2014

Get a Value from an Open Form Field

Assuming your customer form is called CustomerF and the customer's ID is CustomerID then you would set your query criteria to:
=Forms!CustomerF!CustomerID

Now any forms, queries, or reports that you build that use this query as a recordsource will show only related records for the current customer. Here is a sample database that I built that illustrates. I have a simple customer table, order table, and customer form.


click image to enlarge

You can build a query that says "only show me the order records for the currently open customer" like this:


click image to enlarge

Now, as long as your customer form is open and you run this query - or any other reports or forms that are based on it - you will see only the orders for the currently open customer. You can do the same thing with a form, basic listbox, and a button to open another query:


click image to enlarge

Example:

[Forms]![Check QC Project set up]![Text3]  --- this will extract data from the field name Text3 which is in the form Check QC Project set up.

Example in terms of SQL Query:

SELECT AMEX_FEED_MANAGEMENT_02222015.[QC Domain Name], AMEX_FEED_MANAGEMENT_02222015.[QC Project Name]

FROM AMEX_FEED_MANAGEMENT_02222015

WHERE (((AMEX_FEED_MANAGEMENT_02222015.[QC Project Name]) Like ([Forms]![Check QC Project set up]![Text3] & "*")));

Wednesday, October 1, 2014

MSAccess - How to consider some part of text in a form field as a criteria in a query.

Solution 1: 3/17

This is possible using Like command, following is the example and details:


Like ([Forms]![Check QC Project set up]![Text3] & "*")  ------- here this command when placed in the query operates as a criteria.

Query is –

SELECT AMEX_FEED_MANAGEMENT_02222015.[QC Domain Name], AMEX_FEED_MANAGEMENT_02222015.[QC Project Name]

FROM AMEX_FEED_MANAGEMENT_02222015

WHERE (((AMEX_FEED_MANAGEMENT_02222015.[QC Project Name]) Like ([Forms]![Check QC Project set up]![Text3] & "*")));

Check QC Project set up - is the form name
Text3 - is where you enter the text for criteria


Solution 2: 3/19

I can also use MID and In operators:

SELECT Projects_list.Name
FROM Projects_list
WHERE MID(Projects_list.Name, 3) in (Select Project_ids.Project_ID from Project_ids);