473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Macro with two where conditions

62 32bit
I have a form with the where condition to open another form being =="[PropertyID]=" & [PropertyID] which works well in opening up only the pertaining records. I would however like it to only open the pertaining current records. I've tried the code =="[PropertyID]=" & [PropertyID] And [Archived]=False however this opens all records. As always, all help would be much appreciated.
Jan 19 '17 #1

✓ answered by Seth Schrock

Try creating a query to match the data source of the form that you are opening, make sure that the Lease.Archived field is displayed, and manually enter the filter for the PropertyID and see if any of the records have 0 as the value in Lease.Archived.

6 4694
Seth Schrock
2,965 Expert 2GB
You have to build the WHERE string properly. You have the first half, but the And [Archived]=False also needs to be inside double quotes and concatenated to the rest of the string.
Expand|Select|Wrap|Line Numbers
  1. =="[PropertyID]=" & [PropertyID] & " And [Archived]=False"
I tend to add all parts of the criteria that don't need an outside value (like PropertyID) at the beginning so that there is fewer concatenations taking place (for cleaner looks only), so I would switch the order to have it be:
Expand|Select|Wrap|Line Numbers
  1. =="[Archived]=False And [PropertyID]=" & [PropertyID]
Jan 19 '17 #2
glat
62 32bit
Thank you Seth. I used the macro wizard builder so just assumed everything would follow. A problem has arisen as I have [Archived] in more than one table/form giving this message "The specified field '[Archived]'could refer to more than one table listed in the FROM clause of your SQL statement". I've tried adding [Lease.Archived] however nothing is returned when I do this.
Jan 19 '17 #3
Seth Schrock
2,965 Expert 2GB
The brackets go around the table name, then the dot, and then brackets around the field name. [Lease].[Archived]
Jan 19 '17 #4
glat
62 32bit
I have tried this however all fields are empty and there is no error code either.
Jan 19 '17 #5
Seth Schrock
2,965 Expert 2GB
Try creating a query to match the data source of the form that you are opening, make sure that the Lease.Archived field is displayed, and manually enter the filter for the PropertyID and see if any of the records have 0 as the value in Lease.Archived.
Jan 19 '17 #6
glat
62 32bit
Seth, I created a query with the Archived criteria as False which I run in the filter name of the macro with the Where Condition =="[PropertyID ]=" & "'" & [PropertyID] & "'" and it works perfectly. Thank you.
Jan 20 '17 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: steve lord | last post by:
Greetings all, I have a macro that should add a column to a table if the column doesn't already exist. Using the macro condition, how can I test for whether a specific column name in a specific...
7
by: Tobin Fricke | last post by:
I have a wrapper function I use to check the error conditions of various functions: wrap(foo(1,2,3)); (1) while (1 == wrap(bar("fluffy"))) { ... } (2)...
14
by: Urs Thuermann | last post by:
What is the most elegant way to check certain conditions at compile time? I.e. I want a compile time error to be generated if for example the size of a struct is not a multiple of 4 or if one...
7
by: rytsyd | last post by:
what should be the syntax of a macro condition if I want to check if the table name is already existing? I need this condition so that if the table name is existing, the macro will perform other task...
2
by: Russell G | last post by:
Hi I have a number of queries that I have included in a macro. I wish to run this macro at a certian time, usually after hours. I have been playing around with the RUNMACRO command and the...
3
by: swb76 | last post by:
Hi, I have 6 queries in Access that run great. They need to be run in sequence with the first 5 queries writing to tables and the sixth one pops up the final results in datasheet view. Now, how...
3
MMcCarthy
by: MMcCarthy | last post by:
Although some users find Macros simple and easy to use, there are some major limitations to using them. Although you can use macros to perform tasks, there is limited control on when and how those...
11
by: helraizer1 | last post by:
Hi folks, I have a system for an auctioneer and have on the form I have the fields: lot (the item), reserve price () and minimum successful bid so far (). There is then a text box for the user to...
5
by: Peng Yu | last post by:
Hi, It is benifitical to use macro in certain cases. http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/index.html However, I found that it is not easy to debug a macro. For example,...
3
by: Marisol2 | last post by:
I have a macro where I do a transfer spreadsheet from some db queries. I only want the macro to create the spreadsheet if there are results in the query. If not, I want the macro to skip that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.