D
dlhappy
Let me first state that I do not know VBA at all or really how to correctly
use the VBA window.
I have code that was given to me a long time ago when I had used Access 97 in
different databases. Those databases have been converted/saved to the new
format used Access 2007.
I recently created a new database (using Access 2007), Today, I decided that
I wanted two date fields that I used in my other databases.
In my old databases I have two fields, AddDate and EditDate. These fields
work as follows: AddDate - anytime a new record is entered in the database,
the AddDate field and the EditDate fields are automatically filled in to show
the current date. When an existing record is modified in any way, the AddDate
field remains unchanged, but the EditDate field is automatically updated to
show the current date (that is, today's date, the date of the update).
I thought that I could merely copy and paste the code from one of my other
databases to the recently created database in which I had already added the
AddDate and EditDate fields and used all of the same field
definitions/properties that I had in the old database.
The other database (hereinafter "old db") had the following tree (shown in
the VBA window):
Project - ABC
(Folder) Microsoft Office Access Class Objects
FormName
I tried in the new database, in the Database Visual Basic window, via the
various menu items to create/insert a folder called Microsoft Office Access
Class Objects (like in old db). All I could find is inserting a module or
class module. I tried both of those and tried pasting the code. Nothing
worked. Under the project name, I now have a folder named class modules and
two files? for that folder. I tried to remove/delete each one since nothing
works, and now all I get is a "file not found" error message when I try
removing any of them or the folder.
1. How can I delete these modules?
2. How can I insert MS Office Access CLASS OBJECTS (not modules)
and will this work with the code as does old db.
Ths is the actual code:
General - Declarations:
Option Compare Database
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
------------------------------------------------------
Changing General to Form AddDate and Declarations changes to BeforeUpdate
the screen shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
-------------------------------------------------------------------
Either AddDate or EditDate and AfterUpdate
shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_AfterUpdate()
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
--------------------------------------------------------------------
Form Load
shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_AfterUpdate()
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
use the VBA window.
I have code that was given to me a long time ago when I had used Access 97 in
different databases. Those databases have been converted/saved to the new
format used Access 2007.
I recently created a new database (using Access 2007), Today, I decided that
I wanted two date fields that I used in my other databases.
In my old databases I have two fields, AddDate and EditDate. These fields
work as follows: AddDate - anytime a new record is entered in the database,
the AddDate field and the EditDate fields are automatically filled in to show
the current date. When an existing record is modified in any way, the AddDate
field remains unchanged, but the EditDate field is automatically updated to
show the current date (that is, today's date, the date of the update).
I thought that I could merely copy and paste the code from one of my other
databases to the recently created database in which I had already added the
AddDate and EditDate fields and used all of the same field
definitions/properties that I had in the old database.
The other database (hereinafter "old db") had the following tree (shown in
the VBA window):
Project - ABC
(Folder) Microsoft Office Access Class Objects
FormName
I tried in the new database, in the Database Visual Basic window, via the
various menu items to create/insert a folder called Microsoft Office Access
Class Objects (like in old db). All I could find is inserting a module or
class module. I tried both of those and tried pasting the code. Nothing
worked. Under the project name, I now have a folder named class modules and
two files? for that folder. I tried to remove/delete each one since nothing
works, and now all I get is a "file not found" error message when I try
removing any of them or the folder.
1. How can I delete these modules?
2. How can I insert MS Office Access CLASS OBJECTS (not modules)
and will this work with the code as does old db.
Ths is the actual code:
General - Declarations:
Option Compare Database
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
------------------------------------------------------
Changing General to Form AddDate and Declarations changes to BeforeUpdate
the screen shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
-------------------------------------------------------------------
Either AddDate or EditDate and AfterUpdate
shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_AfterUpdate()
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub
--------------------------------------------------------------------
Form Load
shows:
Option Compare Database
Private Sub ADDDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub EDITDATE_AfterUpdate()
End Sub
Private Sub EDITDATE_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Me![EDITDATE] = Date
End If
End Sub
Private Sub Form_Load()
End Sub