I am new to MS Acces and would like to know what does the symbo "!" mean.
For e.g.
1) What does "Tbl!Field" means and how does it differ from "Field" where "Tbl" is a atable name and "Field" is a column name.
I have some code that uses both the formats but not sure how do the two code differ
With recordsets, Tbl!Field would be the recordset (not table) name & the field name. You can also do Tbl("Field").
One advantage of Tbl("Field") is that you can use a variable name, like: Tbl(var1).
You may also see Tbl.Field, but I consider the period to be a property or method and shouldn't be used for fields.
Related
I have homework from Microsoft Access for school and one of the tasks was to make a search form in query, where you type for example 1. grade, 2. grade or 1st year, etc... But the field contains the name of the classes such as IT1, IT2, E1A, E3C, etc... So I could not just make a search form with [Enter Class:] or Like [Enter Class:]&"*" in the criteria column. So I was thinking, that I can use the IIF statement but it doesn't work how I imagined. I think there is a problem with the LIKE statement. I read on forums, that the IIF statement should be used in the field column but I tried the simple examples in the criteria and it worked just fine. So my question is, how I can make a search form, where I type numerous letters with one certain number in it BUT only the number will be read and returned with the same number in classes. Example: I type to search 1. grade and the value will return classes IT1, E1A, E1B, E1C, E1D. This is the line I used in the criteria column:
Like IIf([Enter the grade:]="*1*";"*1*";IIf("*2*";"*2*";IIf("*3*";"*3*";IIf("*4*";"*4*"))))
Just to qualify, I'm beginner in access and databases overall, so there is big possibility, that I'm missing something.
Thank you for help! Cheers!
Assuming input will always start with a number and you want all values containing that number, consider:
WHERE fieldname LIKE "*" & Val([Enter grade]) & "*"
Also assumes values contain only single digit.
data output
I am pretty new to Webi and am having an issue creating a variable. I'm trying to check if there is more than 1 email address for each entity legacy account number and if 1 of the contact names contains "Annual Report". So when I flag each entity legacy account number for no email only the ones without a contact name that contains "Annual Report" will be pulled. In the example above only the yellow groups should be called no email. Right now all of them are being pulled into no email. I have tried using if and match as those are what I am most familiar with. Does anyone have any suggestions?
There are number of ways you could do this. I am going to give an example using two variables, but you could easily combine them into one.
Has No Email Var=If(Match(Upper([Contact EmailAddress]); "NOEMAIL*"); 1; 0)
Annual Report Contact Name Var=If(Match(Upper([Contact Name]); "ANNUAL REPORT*"); 1; 0)
Then you would apply a report filter with two components...
Has No Email Var = 1
AND
Annual Report Contact Name Var = 0
Let me explain a few things...
The purpose of the Upper function is the Match function is case sensitive. If you know your email address are always lower case then you could remove that the Upper function and have it match on "noemail*".
It is significant that I only have a asterisk ("*") at the end of the string being sought. That will only find a match where the corresponding column value starts with that string. If you want it to be true whenever the string is found anywhere in the column being searched you would be asterisks on both ends.
You could also put limiting criteria in your query filter. But here is where thing can get confusing. Within the query filter you can choose the Matches pattern operator. However, the wildcard character is different ("%" rather than "*") and you do not put double-quotes around your search text. So you would have some thing like this...
Contact EmailAddress Matches pattern noemail%
AND
Contact Name Different from pattern Annual Report%
I am sure you noticed I didn't convert the search text to uppercase. In the Query Panel Web Intelligence is case-insensitive and would likely follow the case-sensitivity of the database of the source data. All of our databases are case-insensitive so if yours is case-sensitive you may need to play around this this a bit. Or just go with the approach of creating the variables and report filters as I initially laid out.
If you want a wildcard for a single character rather than multiple characters (which is what "*" and "%" will do) you need to use a "?" within your variable definition or a "_" in your query filter.
Hope this helps,
Noel
I have a uID field linked to an auto number field Num that generates unique, custom numbering for each record in a table.
However the Expression used for the Data type keeps returning an error.
If Field1 = "Cat" then field (uID) must return "C" & [Num]. With the number format "000". ie C001, C010, C121 etc
IIf([Field1]="Cat","C" & formatNumber([Num],3) & [Num],"Unknown")
It seems Access doesn't recognise formatNumber used in this manner.
put this code in your textbox control source
=IIf([Field1]="Cat";"C"+Format([NUM];"000");Null)
this will give you the output what you need.
I've copied the recordsource of a subform to a recordset by RecordClone. this subform source is composed by a query (some tables) and all the fields of this query were renamed like, for instance, id_document to "ID Document", date to "Document Date". what I need is to get those new names instead of the original names. instead of id_document, I want to get "ID Document". I tried to get them in the property or fiels collection, unsuccessfully. if any of you know how to do that, please, help me. I'd appreciate your help.
thanks in advance.
P.S.: this is the way I renamed the field in the query design view:
"ID Document": id_document
Take a look at this excellent answer from Gord Thompson (whose name is familiar to many here):
How to export a table in access to CSV with dot in field names through VBA?
It's not exactly what you're doing (this person wanted to remove a "." from field names) but you're doing something pretty similar. You can probably do a DLookup from a crosswalk table to figure out what the column should be named.
Just build a new table called tblCrosswalk and then fill it like this:
Old New
id_document ID Document
date Document Date
etc... etc...
Then, in the build the CSV header line section, instead of those "Replace" functions, put this:
s = DLookup("New", "tblCrosswalk", "Old = '" & fld.Name & "'")
How do I bind a text box with a field, which doesn't belong to form's "Record Source" table, through the Design View?
Example: I have "Order.cust_id" (Record Source=Order) and I want to display "Customers.name". I believe it is trivial but I have no experience with MS Access. I tried to use the text box "Control Source" property but no luck.
One method would be to convert the text box to a combo box. Then set the row source to include both the cust_Id and the Customer.Name from the customer table. SQL statement example
Select Cust_ID, Name From Customer
Order By Name;
By setting the number of columns to 2 and the column widths; the first column as zero (i.e. "0;6") then the foreign key would be hidden from the user and the customer name would be displayed.
Note this method does force you to have limit to list set to true.
Also you do end up with a drop down list which may not be what you want.
You can use DlookUp as the control source of a textbox:
=DlookUp("[Name]", "Customer", "ID=" & Cust_ID)
Syntax: What to look up, table name, where statement
The Where statement should follow the rules for Jet SQL, which means that you must use delimiters if the field is text or date format.
Note that Name is a very bad name indeed for anything. I suggest you rename the field immediately before things get worse.
It can be useful to know the error(s).
You could create a new View (e.g. OrdersAndCustomerNames), select all the columns you want to use in the form, then instead of using the Order table as Record Source, you would just switch to OrdersAndCustomerNames. You say you have no experience with MS Access, so I am guessing you are not building anything huge and overly complicated, so I would do it this way. I am quite sure it can be done more elegantly but this will do for now.