Using Query Results as Conditions in VBA If / Then Statement

Asked By Eric Brown
02-Nov-09 03:12 PM
Earn up to 0 extra points for answering this tough question.

I am using MS Access 2002 as a quarterly data capture tool. I have built a definitional form (frmDefinition) that captures the parameters of the data points I am collecting (all manual). Within that form I have embedded a subform (sfrmStatus) into which I input the data associated with the individual definition each quarter. The selection of the reporting period is manual from a dropdown box that is populated from a table (tblPeriod) - I have consciously chosen not to code the date / timeframe into the tool.

Here's my challenge: I am trying to code the subform such that only the current quarter is can be editted at any point and the rest of the data is locked. I have created a form (frmPeriod) that contains a check box for each quarter (continuous form linked to the tblPeriod table). The check box may be selected to indicate the current quarter (chkCurrentQ). I have coded that form to only allow one quarter to be checked at any given time.

My theory was that I could run a query against tblPeriod filtering for the single item that was marked as the current quarter and that I could use that query result as the conditional criteria in an If / Then statement in the sfrmStatus subform to lock the records that were not during that quarter. I have not figured out how to reference that data though as a condition. Any help would be very appreciated, including any alternative approaches to this challenge. Thanks in advance.

  re

firoz poil replied to Eric Brown
05-Nov-09 08:19 AM

analyse the following I abstracted from my project change the field and other

SELECT ODC.[order no], ODC.[received date], ODC.[delivered date], ODC.name, ODC.deliveryordno
FROM ODC
WHERE (((ODC.[delivered date]) Between [Forms]![DAT]![Text0] And [Forms]![DAT]![Text1]) AND ((ODC.name)=IIf([Forms]![dat]![Frame88]=2,[Forms]![dat]![namee],[name])));

Add more If condition as per your requirement.

Create New Account