Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of the If..Then Statement

Status
Not open for further replies.

Tuttle2

MIS
Aug 8, 2001
5
0
0
US
Hello,
I am working on a database project that will have an output to a report composed of a series of Check Boxes to indicate completed tasks. A task is considered complete when a given date falls with in a two year window. (Between Date() and (Date () + 730)). I am able to get the query to determine the date criteria, now what is the best way to have the check box property, "Value", change from "No" to "yes"?

I assume the best way to handle this is to macro a "create table" query to generate the date data, send it to a form then generate a report from the form. I have tried this using the "On Load" procedure for the form to run some basic VBA in the background. The code follows:

Private Sub Form_Load()
Me.InitalAssessment.Value = "No"
Me.VitalSigns.Value = "No"
If Me.chkCPR = 1 Then
Me.InitalAssessment.Value = "Yes"
End If
If Me.chkACLS = 1 Then
Me.InitalAssessment.Value = "Yes"
End If
If Me.chkEMT = 1 Then
Me.InitalAssessment.Value = "Yes"
Me.VitalSigns.Value = "Yes"
End If
End Sub

If the date give in the database meets the 2 year criteria, the query assigns a value of "1" to the chkEMT, chkACLS or chkCPR field of the table. Now with an If..Then statement, the value in the chkEMT,chkACLS or chkCPR is evaluated and the .Value of a variety of objects is changed to "Yes". Is there a better way, and is there a way to cut the code down? There are 8 dates and about 30 tasks to compare!
Thanks in advance,
Mark
 
You could use a select case statement or elseir to cut code. You can also put youe sql in the code:
"DoCmd.RunSQL "SELECT Customers.* INTO PrtTbl FROM Customers WHERE ((([Customers].[CustomerID])=c_id));"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top