V
VanceT
I am relatively new to working in VBA in depth, and I am working on a
personal "hobby" project for a note card database (to replace the classic 3x5
note card). Incidentally, I'm using Access 2003.
I am trying to write the code for creating a class for the notes (clsNote)
that has a subclass of comments associated with it (clsComment). The object
model would be something like this:
Note
Comments
Comment
In the "General Declarations" section of clsNote, I have the following line:
Public Comment As clsComment
I have also set a small number of properties for each of the classes (e.g.,
ID, Created, Modified, etc.)
My problem begins when I try to create the objects. I can create the new
note object just fine, but creating a new comment for this is completely
escaping me.
I have a test subroutine that I have been using to figure out how to code
this. Here are the relevant lines of code that I have been using:
Public Sub Test()
Dim objNote As clsNote
Dim objComment As clsComment
Set objNote = New clsNote
Set objComment = New clsComment
With objNote
.ID = 1
.Created = #1/2/2003#
.Body = "This is the body of the note."
End With
With objComment
.ID = 2
.Created = Now()
.Body = "This is the body of the comment."
End With
Debug.Print objNote.ID
Debug.Print objNote.Created
Debug.Print objNote.Body
Debug.Print objNote.Comment.ID
Debug.Print objNote.Comment.Created
Debug.Print objNote.Comment.Body
End Sub
Any suggestions? Where am I making a mistake? Any help or direction would
be greatly appreciated.
Thanks.
VMT
personal "hobby" project for a note card database (to replace the classic 3x5
note card). Incidentally, I'm using Access 2003.
I am trying to write the code for creating a class for the notes (clsNote)
that has a subclass of comments associated with it (clsComment). The object
model would be something like this:
Note
Comments
Comment
In the "General Declarations" section of clsNote, I have the following line:
Public Comment As clsComment
I have also set a small number of properties for each of the classes (e.g.,
ID, Created, Modified, etc.)
My problem begins when I try to create the objects. I can create the new
note object just fine, but creating a new comment for this is completely
escaping me.
I have a test subroutine that I have been using to figure out how to code
this. Here are the relevant lines of code that I have been using:
Public Sub Test()
Dim objNote As clsNote
Dim objComment As clsComment
Set objNote = New clsNote
Set objComment = New clsComment
With objNote
.ID = 1
.Created = #1/2/2003#
.Body = "This is the body of the note."
End With
With objComment
.ID = 2
.Created = Now()
.Body = "This is the body of the comment."
End With
Debug.Print objNote.ID
Debug.Print objNote.Created
Debug.Print objNote.Body
Debug.Print objNote.Comment.ID
Debug.Print objNote.Comment.Created
Debug.Print objNote.Comment.Body
End Sub
Any suggestions? Where am I making a mistake? Any help or direction would
be greatly appreciated.
Thanks.
VMT