So my project is to calculate a list of deadlines for various items based off a conference start date. I have been trying to figure out how to use Access 2007 (employer software) to generate the due dates based off a change in the conference start date.
My failures include: Write Conflict Message <-- trying to get rid of this Not recognizing the variable Tried a Query, but couldn't get the query to show in the Form
ConferenceStartDate is the column containing the user input on the Form, and the variable I want to base all other dates on. I have the Form use the "Before Update" subroutine to make the change.
Private Sub ConferenceStartDate_BeforeUpdate(Cancel As Integer)
' Concept is to enter Volume and Conference Date Start/End and have it calculate the rest of the dates
' Then compare to current date and create a report on over due, next due, etc
' Then create emails based on templates for next data
Dim rstNameList As DAO.Recordset
Set rstNameList = Application.CurrentDb.OpenRecordset("Table1", dbOpenDynaset)
Dim startDate As Date
Dim endDate As Date
Dim recordNumber As Integer
Dim stringRecordNumber As String
Dim stringSQL As String
' *** Second Attempt
' Gives Write Conflict message. Weird, if you say Update, moving to the next record does not update, but saying No Update actually updates the record.
recordNumber = [ID]
stringRecordNumber = "ID=" & CStr(recordNumber)
' Gets the start date of the conference
startDate = [ConferenceStartDate]
' Add seven "d"ays tp startDate
endDate = DateAdd("d", 7, startDate)
' rstNameList.FindFirst stringRecordNumber
' rstNameList.Edit
'rstNameList!VolumeName = "MC-130"
' rstNameList!ConferenceStartDate = startDate
' rstNameList!ConferenceEndDate = endDate
' rstNameList.Update
' rstNameList.Close
' Gets rid of the Write Conflict error message
' Command doesnt work
' If Forms("Table1").Dirty Then Forms("Table1").Dirty = False
' *** First Attempt
'Works to add
'Set db = CurrentDb
'Set rs = db.OpenRecordset("Table1")
'rs.AddNew
'rs("ID") = 5
'rs("VolumeName") = "KC-130"
'rs("ConferenceStartDate") = "1/1/1111"
'rs("ConferenceEndDate") = "1/2/1212"
'rs.Update
'rs.Close
' *** Third Attempt
' Doesn't actually update
' stringSQL = "UPDATE Table1 SET [ConferenceEndDate] = #" & CStr(endDate) & "# WHERE " & stringRecordNumber
' DoCmd.RunSQL stringSQL
End Sub
Any one have any idea how to not have a Write Conflict Message and the dates update based of input from a Form of a single date?
Thanx!