One Field Meets Criteria Of Another?!?!
Jan 16, 2007
Hi,
I have one field, for this example, FieldA and another FieldB.
I would like the following:
If fieldA =1 then FieldB must = 1 or 3 or 4. If not then I would like a message box saying it needs to check. Otherwise I don't want anything to happen.
How can I do this? and where do I put any expressions?
thanks
Sue
View Replies
ADVERTISEMENT
Jul 29, 2015
Windows XP
MS Access 2007
VBA experience is very limited
So in my forms 'BeforeUpdate' property I want to validate whether a condition is met. The condition is whether 'any one of 4 fields contains something (text or number)'. I have written this code for validating a single condition and it alerts if the field is left blank. This code returns a warning message when the field is blank.
If Me.[txtObjective] & "" = "" Then
MsgBox "A 'Problem Objective' is required, please complete this field.", vbOKOnly
Me.[txtObjective].SetFocus
Cancel = True
[code]...
how to write the SetFocus part. And I dont know if this is correct anyway.
View 6 Replies
View Related
Nov 4, 2005
Hey, I know this is probably a simple thing to do, but I couldn't find it anywhere on the web so hopefully someone here can help.
I have a column of UPC codes which are a bunch of #'s. I need to find the ones that have more than or less than 12 characters.
Thanks
View 2 Replies
View Related
Jul 17, 2014
I have a Access table that stores BatchNo,Scandate,NewBatchNo . As I can't attach Access database here so I have exported data from Access to Excel in Sheet1 to show how the data is stored in Access table.
Now I have to write code in VBA that will check the last NewBatchNo in the table . In the attached workbook its 194389. Now vba code should check the NewBatchNo which are blank before 194389 . Now in the records where NewBatchNo is blank , it should add the corresponding BatchNo,ScanDate in the listbox1 in form1.
e.g Sheet2 in the attached workbook stores Bathcno and Scandate of those records where NewBatchNo is null and before the Last used NewBatchNo which is 194389 in our example.
View 4 Replies
View Related
Mar 15, 2013
I'm an amateur (is there such a thing as having databases as a hobby?) with little training. I volunteered to organize a growing volunteer group I'm a part of by making a simple database for the volunteer office staff. One of the things I want it to do is make name tags for our weekly meetings. I don't want to print one for each name on our list because the list is over 400 names long with only around 35 regular attendees. I made two tables--one is the MakeNameTag table that lists regular attendees (it is a lookup field on the Names table).
The other is the Absences table. It has two fields; DateOfAbsence and MakeNameTag. If someone misses a meeting (does not pick up their name tag), their name is added to the Absences table. A query then filters the table for dates in the last 28 days. If their names shows up four times in the last 28 days I want for their name to be deleted from the MakeNameTag table. How to do that automatically? Our office volunteers have minimal PC skills, so the solution needs to be very user-friendly.
View 3 Replies
View Related
Aug 8, 2014
I have a table [PickData] in a WMS (Warehouse Management System) database, that records details of each item picked. The key fields are;
[Movement] - a unique ID for a collection of items to be picked.
[ToAssignRef] - the order ID
[Product] - the product!
[Picked] - the date/time the item was scanned
[Pick Actioned] - the date/time the [ToAssignRef] was completed
[Reason] - A code to indicate why an item could not be picked - AKA F3'd
An operative would be allocated a movement, connected to the [ToAssign Ref], containing a number of products to pick. If an item can not be picked for some reason the operative presses F3 and selects a reason (no stock, damaged etc). These F3'd items (other stock allowing) will later be picked on a different [Movement]. I need a query to identify the subsequent [Movements] and the associated fields following the occurance of an F3'd [ToAssignRef] & [Product].
I have a query, but it runs very slowly (perhaps due to the DB size currently 780K records). Is this the right approach, is there a better (faster) way to do this?
Code:
SELECT PickData.ToAssignRef, PickData.Product, PickData.Picked
FROM PickData
GROUP BY PickData.ToAssignRef, PickData.Product, PickData.Picked
HAVING (((DCount("[Movement]","[PickData]","([ToAssignRef]='" & [ToAssignRef] & "') AND ([Product]='" & [Product] & "')"))<>0));
View 2 Replies
View Related
Mar 5, 2013
I am trying to create a report which basically includes the following:
Company, Wages, Contribution.
Each company reports wages for each employee every month. Then they also contribute to a general fund based on a percentage of the wages. For instance:
Company---Employee---Wages---Contribution
CompanyA---EmployeeA---$4000---$40
CompanyA---EmployeeB---$3800---$38
CompanyA---EmployeeC---$3800---$38
CompanyB---EmployeeA---$4200---$42
CompanyB---EmployeeB---$4200---$42
...and so on.
Each employee is required to contribute, in this example, 1% of gross wages to the general fund.
On occasion, the company does not pay in the required 1% of gross, say, for CompanyA EmployeeA, they only paid in $35.
Here is what I need to do. If any contribution amount for any employee is incorrect, I want to display all the records for that company, not just the incorrect ones. The report is grouped by Company, and may contain dozens of companies.
I am already passing a number of criteria to the report using a filter, including the date range and other fields which are informational.
View 6 Replies
View Related
Jul 12, 2013
Is it possible to insert text from a textbox on a form (Data) when a combobox on (Data) meets a criteria?
Example: Test: IIf([Results]="Positive" text207)
So if the Results combobox is Positive then the text from Text207 is inserted.
View 9 Replies
View Related
Jul 3, 2014
I have a module that is in Excel that is connecting to a back end database. I am trying to pull data from a table that meets a number of conditions. With the following statement, it is not returning any records,even though I know there are records that meet all of the conditions. I suspect the problem is with the last condition. In that condition I am trying to say that pull in records where it has been at least 14 days since the last review.
Code:
strSQL = "SELECT tblsojrol_oc.* FROM tblsojrol_oc WHERE tblsojrol_oc.[Status] = 'Pending' AND tblsojrol_oc.[1st Review Date] IS NOT NULL AND " _
& "tblsojrol_oc.[3rd Review Date] IS NULL AND (DateADD(Day,14,tblsojrol_oc.[2nd Review Date])) >= #" & dt & "#;"
objRs.Open strSQL, objConn, adLockReadOnly
View 14 Replies
View Related
Dec 5, 2012
I have a main table which is autonumbered on unitid, I have another table which is linked via the unitid which holds items purchased for the main table, so the second table is a subform of the suppliers and will have multiple entries of the same unitid. What I would like to do is when an item is entered into the second table, check the main table to see if it exists, if it does populate the unitid field with the unitid from the main table, and if not exist create a new record in the main table with the next unitid number.
This in essence is what I want, bearing in mind that the tblinvoices is a subform and the tblmain is not open.
If ([tblinvoices]![Unit] = [tblmain]![Unit]) Then
[tblinvoices]![UnitID] = [tblinvoices]![UnitID]
End If
View 3 Replies
View Related
May 11, 2013
I have a query where I prompt for a Report_Date to create a new field; Report_Date:[ Enter date for report]
Is it possible to use the result from this prompt as a criteria in a different field?
for example, Order_Date based on the criteria of <=[Report_Date]
View 4 Replies
View Related
Sep 29, 2014
I have db that tracks vehicle mileage and servicing
I have created query to show which vehicles are due service by the mileage
My issue is some manufacturers set different service intervals
E.g.
car manufacture A = service intervals every 10,000
car manufacture B = service intervals every 20,000
but i would like to give pre warning so I'm using between criteria
here is what i have much appreciate if there is a better why of doing this
im using Dmax to find the last mileage entered for the vehicle
findLast: DMax("[vehicle mileage]","[vehserviceTbl]","([vehicleidimp]= " & [vehicleid] & ")")
now the criteria
Ifs([make] = "A" , Between 9000 and 10000
ifs ([Make] = "B" , between 19000 and 20000
can't get the red text to work shows blank when query runs
View 1 Replies
View Related
Jun 1, 2005
Hi there
I have a table of which I need to count the instances of one of the fields.
The trouble is that I need to return two different counts based on two different criteria.
I don't really want to duplicate the table just to be able to achieve this, and I wanted to be able to construct it in a way that I can use in my ASP page which interrogates the database.
Of course everything I've tried applies the two criterias at once to the results. Stuck on this one, any help much appreciated. :confused:
View 13 Replies
View Related
Jan 9, 2007
Nearly finished my 1st database thanks to the people here.
Just need direction on one more thing:-
i need to input a "return date" into a field on a form and then click a button to run a query based on that date field to list all carts to return on that date. We always have to put in different dates and so 1 set query would be no good.
I assume i need some kind of criteria in the query. Anyone help?
Many Thanks Ben
View 2 Replies
View Related
Jul 1, 2005
You will see it is a simple problem if you know what your are doing.
When entering the joining date I would like the Status to change automatically to Member and when the renewal date is reached I would like the status to automatically change to Renewal but I am unable to work out a formula for this.
Many Thanks,
Fredfox.
View 7 Replies
View Related
Oct 4, 2005
I am not sure how to search for this so if there is another thread with this example please direct me in that direction. What I am trying to accomplish in my query is the following:
I am bringing data in from another source in the following table
ID Date1 Date 2
I want a query to do the following based on dates entered on the switchboard in a beginningDate field and EndingDate field
ID Date1 Date2 Final1 FInal2
If Date1 is between beginning and ending date I want it to put a yes in Final1 if Date2 is between beginning and ending date I want it to put a yes in Final2. Both can have yes'.
I tried doing an if statement in my expression as follows: IIF([Date1] between [Forms]![FrmSwitch]![BeginningDate] and [Forms]![FrmSwitch]![EndingDate], "Yes", "") but nothing comes up. My switchboard is always open with the dates in an unbound field.
Any suggestions???
View 5 Replies
View Related
Oct 5, 2005
I am wondering if it is possible to use a table/field identifier as part of a criteria expression in a query.
The field that I need to use in the expression is not a part of the focus table, so I think I need to use a full identifier, if that is possible. I have seen such identifiers used for controls on forms, but never fields in tables.
For example, something like the following as a criteria expression:
<>[Tables]![tblUserData]![UserId]
Obviously, that didn't work. My question is, is it possible to identify a field from another table as part of a criteria in a query. If so, how?
Just in case it helps, the reason I am doing this is I am trying to create an append query that only appends data that is not already there.
View 5 Replies
View Related
Feb 15, 2006
Hey guys, apologies in advance for a question which you may have answered many times, I have searched the net, my textbook and these forums but to no avail.
I have a table, 'tblStock'.
I have two fields within this table, 'Stock Level' and 'Minimum Stock'.
I want to run a query on this table, finding all records where the value in 'Stock Level' is LOWER than the value in 'Minimum Stock'.
How would I go about setting up this query? What criteria would I type? I have tried typing <"Minimum Stock" in the criteria for 'Stock Level' but it didn't work.
Thanks in advance... this will be a big help. :)
View 7 Replies
View Related
Jun 14, 2006
I have a query drawing information from two tables. The first table has information about a product, and the second table holds all the faults found per product. So any one product can have anything from 1-14 faults. I have created a report from the query, but the Fault item that I put on it only ever shows the first fault for that product. Is there some way of fixing this at report level, or on the query?
The tables are connected through the ID field, but the primary key for the faults table is another autonumber. Ex:
Primary Key___ID___Fault
___1__________ 1____fault 1
___2__________ 1____fault 2
That's two faults for the same product. Maybe I could create new fields in the query like Fault1: [Fault] with criteria set to primary key = 1? And one for each fault? But when I do it, it sets that criteria to the entire query, so the results end up blank because the "primary key" field doesn't exist on the product table.
I guess what I'm asking is can you set a criteria for just one field of your query to follow? Or can I resolve this issue in the report design?
Many thanks,
Tom
View 1 Replies
View Related
Aug 10, 2006
Hi All,
I need to make a search criteria within the same field,
for example here 'Demo' should selected from 'xxx' to 'xxx' number.
Thanks for reading, any suggestion would be appreciated
good day :-)
View 4 Replies
View Related
Jan 22, 2006
Hi, I have a field in a form that says when you are able to book a certain event, and i want the field in which the event can be booked, to remain unable to be edited until the tick box says yes. Is that possible?
Chris
View 4 Replies
View Related
Aug 23, 2013
In an Access 2010 query is it possible to set a criteria on a field (Results), that If it is "Negative" then another field (Variants) has the text "None Detected". Or is it easier to do that in the Variants field?
View 1 Replies
View Related
Apr 3, 2012
I have a query in Access with the following fields (grouped):
"Name" "Facility" "Number of Visits"
I want to limit the query to only pull those names that have at least one visit to a specific facility (let's say facility "A"), but I also need to see all of the other facilities that those who visited Facility A visited. So in this case "= "A"" in the criteria section of the Facility field wouldn't work. I think I need to plug something in the criteria section under the Name field, but I am not sure what.
View 1 Replies
View Related
Dec 18, 2014
In the query I am trying to put a criteria in a date field. What I want is to get all the data that fits in one month.
I use Microsoft access 2010
View 5 Replies
View Related
Nov 16, 2007
I think the title pretty much sums it up....
I have a query where data is first sorted by user input; first field's criteria: [fieldname], then by another field's criteria: Is Null.
I know there are records containing null values in the second field, as I have run a select query with the criteria: Like "*", to make sure they are null, and not zero-length-strings.
The query is refusing to return any results...
Any ideas?
View 10 Replies
View Related
May 27, 2005
Apologies, this was posted as a reply to a previous thread I submitted but its not related to the title anymore (dlookups).
I have a query that looks up a payrate value for an employee in a payrate table. It uses the appropriate value to determine the pay rate at teh time an employee has worked (DateWorked). On top of this I also need to introduce a parameter criteria on the DateWorked to allow the user to run the report for a time frame. This is where I get stuck as I cant seem to get it to work properly if I introduce another criteria on the field
The query that works great (without the second criteria) is as follows;
SELECT tblTimeCard.EmployeeId, tblTimeCard.TimeCardId, tblTimeCardHours.Task, tblTimeCardHours.Hours, tblTimeCard.DateWorked, tblPayRates.DateFrom, tblPayRates.DateTo, tblPayRates.PayRate,
tblTimeCardHours.Hours*tblPayRates.PayRate AS Cost
FROM (tblTimeCard INNER JOIN tblTimeCardHours ON tblTimeCard.TimeCardId = tblTimeCardHours.TimeCardId) INNER JOIN tblPayRates ON tblTimeCard.EmployeeId = tblPayRates.EmployeeId
WHERE tblTimeCard.DateWorked Between [tblPayRates].[DateFrom] And [tblPayRates].[DateTo];
This is where I need to introduce another criteria where tbl.TimeCard.DateWorked Between [Enter Date From] And[Enter Date To]
when I try this I must have one of the joins wrong as I get all the payrate values for each date worked even if they are outside the dateworked criteria set by the second criteria.. I hope I have explianed this ok. Can someone please advise where I should be looking - many thanks
View 1 Replies
View Related