ms access - How can I find records in a table / recordset based on the result of a query on the same table? -


The first condition I am trying to return to the record for a warning system based on two conditions is that tomorrow's date [Date () + 1] for the type of booking book in the system with value. If that type of job also requires a type of value of A (in the second record) and the result field value is "not accepted", we need to return a warning.

Example table:

  Job Type Number Company Date Results 58129 B3 22/03/2013 58129 A3 20/03 / 2013 Approved 58129 C3   

So far I have succeeded in creating the SQL query in VBA to return the results of the first condition and is prevented through the result to return the relevant job. How can I insert these jobnets as criteria for the second SQL query or is it possible to add all the parameters to a SQL statement?

My SQL so far:

  strSQL1 = "SELECT I.JobNumber, I.Type, I.Company, I.Date, I.Result" & amp; _ "To tblInspection I" & amp; _ "WHERE (((I.Type) = 'b') and (idad) = date () + 1);" StrSQL2 = "SELECT I.JobNumber, I.Type, I.Company, I.Date, I.Result" & amp; _ "To tblInspection I" & amp; _ "WHERE (((I.Type) = 'A' and ((I.Result) 
'Approved');"

Any help would be greatly appreciated.

You can get one field from one or the other table it will provide an error if more than one The row is returned, but whether one or more rows will be returned or not depends on your data. If this is possible, then you will need to add another criteria, such as the date.

  SELECT IJobNumber, I.Type, I.Company, I.Date, I.Result, (SELECT results from tblInspection q to WHERE q.JobNumber = i.JobNumber and Results = "Approved No "and type =" A ") as a result from tblInspection I to I.Type = 'B' and I.Date = Date () + 1    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -