Calculations in forms and updating tables

  • Thread starter Thread starter Argeey
  • Start date Start date
A

Argeey

Guest
MS Access help needed
I need help to make certain functions work in an Access 2000 database I am trying to construct.

1. In a form I have 3 fields:- Date Logged, Priority, Complete by.
Date Logged and Complete by are date fields and Priority is a number field. What I want is to enter a date in the Date logged field and a number between 1 & 4 in the Priority field. I want the computer to enter a date in the Complete by field. If the priority is 1 then the date should be Date logged +1. If Priority is2 then it is +3, Priority 3 is +7 and priority 4 is +14. Can someone please tell me the syntax to make this work and tell me where to enter it.

2. My next query is, once I have a Complete by date, how do I update the table?
 
You can put this in the after update event of your priority field

if isNull(DateLogged) = false then
Select Case Me.Priority
Case 1
CompleteBy = DateAdd ("d", 1, DateLogged)
Case 2
CompleteBy = DateAdd ("d", 3, DateLogged)
Case 3
CompleteBy = DateAdd ("d", 7, DateLogged)
Case 4
CompleteBy = DateAdd ("d", 14, DateLogged)
Case Else
MsgBox "Not a valid proiority number"
End Select
end if

I assume you want to increment by days, hence the "d" which represents the day part of the date format.

About your second question, you should really have your fields bound to the table.
 
In the after update event of the field priority add some code something like

Select Case Priority

Case is = 1

dblA=1

Case is = 2

dblA=3

Case is = 3

dblA=7

End select

Me.CompleteDate=DateAdd("d",dblA,Me.DateLogged)

dblA is a double representing the number of days.

I am sorry I do not understand the question how do I update the table.
 
Good call. Go the Wallabies!
 

Users who are viewing this thread

Back
Top Bottom