473,320 Members | 1,978 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,320 software developers and data experts.

Help to modify a macro where condition in Access 2010

6
Hello,

I desperately need help to modify a where condition that was created when I added a button to open a form and find specific data by to display.

The form currently opens and displays a form filtered by the task num (where condition below).

Expand|Select|Wrap|Line Numbers
  1. ="[task Num]=" & "'" & [task Num] & "'"
This works great. When I click on the button, a form (Contractors) pop-ups and displays all records filtered by task num. Now, I would like to perform another filter on the field “contractor”. So, the form will open, filter on task num AND contractor. How can I modify the above where condition to add the contractor field?

Both my task num and contractor fields are text data types. I am using Microsoft Access 2010.

My Contractor form is using a query for the record source.

I appreciate your help and thank you in advance for responding. :-)
Oct 23 '13 #1
6 2057
Rabbit
12,516 Expert Mod 8TB
Append an AND operator to the criteria string along with your new criteria.
Oct 24 '13 #2
mlgmlg
6
Hi Rabbit, thank you so much for your response.

I tried appending the "AND", but it is not working. Not sure if I am appending it correctly.

Expand|Select|Wrap|Line Numbers
  1. ="[Task Num]=" & [Task Num] & " AND Contractor = '" & Contractor & "'"
:-(
Nov 3 '13 #3
mlgmlg
6
Hi Rabbit,

This is the form I am trying to display.

When a user clicks on a button, it will display the Rev Form by Task Num. We are trying to see what the next rev num to use for a particular contractor. The macro code works fine to display the associate task numbers, but I would like to do one more filter and that is to filter by contractor. So, the end results should display like Sample 2.
Expand|Select|Wrap|Line Numbers
  1. Sample 1:
  2. Rev Num    Task Num      Contractor
  3. Rev-2    PJ55145      Jamsinc
  4. Rev-1    PJ55145      MLRNet
  5. Rev-0    PJ55145      ToolsLink
  6. Rev-3    PJ55145      ToolsLink
  7. Rev-4    PJ55145      ToolsLink
Expand|Select|Wrap|Line Numbers
  1. Sample 2:
  2. Rev Num    Task Num      Contractor
  3. Rev-0    PJ55145      ToolsLink
  4. Rev-3    PJ55145      ToolsLink
  5. Rev-4    PJ55145      ToolsLink
Nov 3 '13 #4
Rabbit
12,516 Expert Mod 8TB
Task Num looks like a string to me and not a number. You need to surround string values in single quotes like you were doing originally. But you dropped it in your new code for some reason.
Nov 3 '13 #5
mlgmlg
6
Yes, this is the actual macro statment:
Expand|Select|Wrap|Line Numbers
  1. ="[task Num]=" & "'" & [task Num] & "'" 
I was try to modify the original macro to add the statement to filter the contractor data as well, but I am having no luck with adding the AND to the end. Ugh! :-(
Nov 4 '13 #6
Rabbit
12,516 Expert Mod 8TB
You just need to take your code from post #3 and put your quotes back in.
Nov 4 '13 #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...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been...
1
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
5
by: neelsfer | last post by:
I got a new work laptop last week with Access 2010 pre-loaded.I also installed the new Office 2010 service pack 1. I then loaded 2 of my regularly used Access 2007 + service pack 2 applications on...
4
by: jbrumbau | last post by:
Hello, In Access 2010/2007, how do you prevent users from flipping into design view from the ribbon? I do not want to hide the entire ribbon (DoCmd.ShowToolbar "Ribbon", acToolbarNo) or even the...
3
by: john latona | last post by:
hi! i realize that access 2010 does not have the username and password function built into it, so i am trying to build it into my db. i have a "login form" with text fields titled username and...
4
beacon
by: beacon | last post by:
Hi everybody, My title may not exactly describe my issue, so please forgive my lack of creativity today. I've got a database that was created in Access 2003 that I've opened in Access 2010. I...
11
by: Redbeard | last post by:
I have just upgraded to Access 2010 (64 bit) from Access 2007. There were a few minor issues in the database which I have resolved but this one piece of code just won’t work. I do not write VBA but...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.