Programming Access to give next date Automaticaly

  • Thread starter Thread starter Lonely Sayi
  • Start date Start date
L

Lonely Sayi

Colleagues

I have just created a database for monitoring how patients
keep appointments for Asthma etc. Now, a date entry is
made when a patient turns up for their first appointment.
What I would like to do is ensure that the next
appointment date is generated at the point the first
appointment is met. This should be six monthly and
annually. How do I go about doing this. Please help if
this possible.

Lonely
 
To automatically generate the next appointment in 6 months time, use the
AfterInsert event procedure of the form. Build a string that represents an
Append query statement, and Execute it.

Example:
Private Sub Form_AfterInsert()
Dim strSql As String
strSql = "INSERT INTO ...
dbEngine(0)(0).Execute strSql, dbFailOnError
End Sub

You will need to concatenate the values from the newly created record in the
form into the SQL string. If you are not sure what the SQL statement should
look like, create a mock Append query statement with sample values (Append
on Query menu in Query Design view), and switch it to SQL View (View menu).

There is a flaw in this approach though: this generates the next appointment
programmatically, but what happens after that? You will need some mechanism
to create the following appointment as well: perhaps when the patient
actually attends the projected appointment?
 
Back
Top