How do I mark values that exist in 2 different fields - ms-access

I'd like to mark values that exists in both the field "ID" and the field "NUMBER".
The value is not important (e.g. True/False or -1/0)
I have tried the following but that did not work.
DESIRED OUTCOME: DLookUp("ID","Table1","NUMBER= ID")

Try this:
DESIRED OUTCOME: (DLookUp("[NUMBER]","[Table1]","[NUMBER] = " & [ID] & "") = [ID])

Related

Access Dcount function with 4 criteria

I appreciate some help
I am trying to use Dcount function with 4 criteria
I have a text box in a form to count records on table_orders
The DCount function has 4 criteria:
The ID field in table_orders has to match the Form ID field
The field nature on table_orders has to be null
The field team on table_ordres has to be different than “Canceled”
The field ram (yes/no field) in table_ordes has to be “No”
I´ve been trying in many different ways with no success
This is my last try:
=DCount("*","Table_orders","ID=" & [ID]& " AND IsNull(nature)=true" & " AND [team] <> "Canceled" & AND [ram] ="No")
Try this:
=DCount("*","Table_orders","ID = " & [ID] & " AND [nature] Is Null AND [team] <> 'Canceled' AND [ram] = 'No'")

Power BI - How to combine all the values in a column from another query (table) in Power Query

I'm trying to write a power query to where I can join all the values of a column from another query (table) into a single line.
Example:
Table from Query 1
Outcome: I want it to return a text like:
[2019-09],[2019-10],[2019-11],[2019-12],[2020-01],[2020-02]
I'm trying to put this in my other query, within a JSON code, where the text combine function is (Value).
{""DataModelName"":""[AllStreams].[Month Year]"",
""Caption"":"""&Date.ToText( DateTime.Date( Date.AddDays(DateTimeZone.UtcNow(),0) ) , "yyyy-MM")&""",
""Value"":""["
& Text.Combine(Table.SelectColumns(FilterList_PV)[Date]), "" ) & "]"",
""Operand"":0,
""UnionGroup"":""""}
Let me know if this is possible! Thanks!
Here's another way: Text.Combine(List.Transform(Table[Column], Text.From),",")
you can do this with one big step, but shown here in smaller pieces
Assuming column in question is named Date
Add a column we can use to group on, all with same value
Add column that converts each date into text surrounded by [] showing year and month
Group on the first added column, combining all row values
Remove extra column
#"Added Custom" = Table.AddColumn(#"PriorStep", "Custom", each "[" & Text.From(Date.Year([Date])) & "-" & Text.PadStart(Text.From(Date.Month([Date])),2,"0") &"]"),
#"Added Index" = Table.AddIndexColumn(#"Added Custom", "Index", 0, 0),
#"Grouped Rows" = Table.Group(#"Added Index", {"Index"}, {{"Count", each Text.Combine( List.Transform([Custom], Text.From), ","), type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Index"})

Concat Related Function Returns Error

I am attempting to use Allen Browne's ConcatRelated() function, but I am getting an error of:
Error 3061: Too few parameters. Expected 1
Below is the syntax I input into my query ->
ConcatRelated("Product","[_ProdInfo]","OrderNumber = " & [OrderNumber])
What should I change so that this does not produce the error and displays the results I am after?
Further explanation:
Field Name is Product
Table Name Is _ProdInfo
The field to match on is OrderNumber and it is a short text type
As ConcatRelated() link describe:
If the foreign key field is Text (not Number), include quote marks as
delimiters, e.g.:
"[ForeignKeyFieldName] = """ & [PrimaryKeyFieldName] & """"
And since your OrderNumber is a text field, add the needed quotes:
ConcatRelated("Product", "[_ProdInfo]", "OrderNumber = """ & [OrderNumber] & """)
Or with single quotes:
ConcatRelated("Product", "[_ProdInfo]", "OrderNumber = '" & [OrderNumber] & "'")

Multi-field searches in Access with blank fields

I have a table in access (simplified) with fields of sex, first name, last name, and phone number.
Sex First Last Phone
F Alice Smith
M Bob 111-111-1111
F Smithe 111-111-1112
M Charlie Smith
F Eve Drop 111-111-1113
I have created a form along with a query to search for the records, using the criteria of
Is Null Or Like "*" & [Forms]![Search]![Criteria] & "*"
where Search is the name of my form, and Criteria is the name of the individual entries on my form.
Right now, if I search for Sex F and the last name Smith, and leave the first and last name fields blank, I want to be able to see the records for "Alice Smith" and "Smithe". But instead, I only get the record of "Alice Smith". Furthermore, if I search for Sex F and phone number 111, I get results for Alice, Smithe, and Eve. Similarly, if I just search for phone number alone, I will get all five records.
I'm assuming that I'm doing something wrong here, but I can't tell what it is. Based on the conditional logic of or, the results should be either Null or 111 (and similar for the other fields), so I guess it is behaving as expected. I've tried xor however, and I get the same result (and even if it does work the way I'm thinking it would, it would seem bad since a blank entry would be interpreted as null instead of "search every entry". I've tried using iif, which should be the correct way to do this, but it appears to not work when placed in the criteria field. Am I missing something here?
Null is the special value (with the meaning not-known) and it is NOT the same as a blank text field, which has the value "" (empty string).
So adjust your criteria to accept the value "".
For multi-field search use criteria for each field like this:
WHERE
([Sex] Like "*" & [Forms]![Search]![CriteriaSex] & "*"
OR Nz([Forms]![Search]![CriteriaSex],"")="")
AND ([First] Like "*" & [Forms]![Search]![CriteriaFirst] & "*"
OR Nz([Forms]![Search]![CriteriaLast],"")="")
AND ([Last] Like "*" & [Forms]![Search]![CriteriaLast] & "*"
OR Nz([Forms]![Search]![CriteriaLast],"")="")
AND ([Phone] Like "*" & [Forms]![Search]![CriteriaPhone] & "*"
OR Nz([Forms]![Search]![CriteriaPhone],"")="")
In this case every condition will be TRUE if corresponding criteria field is empty.
Another way to build this query would be to build a string based upon which fields are populated.
q = "SELECT * FROM table "
w = ""
IF(nz([Forms]![Search]![Criteria1],"")<> "") THEN
w = "WHERE [table]![field] like '*" & [Forms]![Search]![Criteria1] & "*'"
END IF
IF(nz([Forms]![Search]![Criteria2],"")<> "") THEN
IF (w="") THEN
w=" WHERE "
ELSE
w=w & " AND "
END
w = w & " [table]![field] like '*" & [Forms]![Search]![Criteria2] & "*'"
END IF
IF(nz([Forms]![Search]![Criteria3],"")<> "") THEN
IF (w="") THEN
w=" WHERE "
ELSE
w=w & " AND "
END
w = w & " [table]![field] like '*" & [Forms]![Search]![Criteria3] & "*'"
END IF
q = q & w

Combobox issue in Access VBA

I am trying to set a combobox's value to the default one, the problem is the data source is from a query that return an integer type , I want my default value to be "*", when I try this :
Private Sub LabelWklstID_DblClick(Cancel As Integer)
Me.WorklistIDSelector.Value = Mid(Me.WorklistIDSelector.DefaultValue, 2, 1)
End Sub
it didn't work getting " Invalid value " error, but when I try an int it works :
Me.WorklistIDSelector.Value = 1
How can I make my combobox accept the "*". Any Help will be appreciated
Edit:
RowSource=
SELECT tWorkList.WorkListID, tWorkList.ProjectID FROM tWorkList GROUP BY tWorkList.WorkListID, tWorkList.ProjectID HAVING (((tWorkList.ProjectID)=[Forms]![fMain]![ProjectID])) ORDER BY tWorkList.WorkListID;
Bound Column = 1
Column Widths =2,54cm
select tworklistID as ID, other fields from tworlklist etc
UNION
select '*" as ID, 0,0,0(dummy blank other fields)