3

So I tried following these questions as guides:

Here is the error I'm getting whenever I click a control on my form:

error_msg

Here is my interface:

ITransactionRecord

Option Compare Database
Option Explicit

Public Property Get TRANSACTION_DATE() As Date
End Property

Here are my classes:

LedgerRecord

Option Compare Database
Option Explicit

Implements ITransactionRecord

'from interface
Private tTRANSACTION_DATE As Date

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date
    ITransactionRecord_TRANSACTION_DATE = TRANSACTION_DATE
End Property

Public Property Get TRANSACTION_DATE() As Date
    TRANSACTION_DATE = tTRANSACTION_DATE
End Property

Public Property Let TRANSACTION_DATE(ByVal newTRANSACTION_DATE As Date)
    tTRANSACTION_DATE = CDate(Format((newTRANSACTION_DATE), "m / d / yyyy"))
End Property

TransferRecord

Option Compare Database
Option Explicit

Implements ITransactionRecord

'from interface
Private tTRANSACTION_DATE As Date

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date
    ITransactionRecord_TRANSACTION_DATE = TRANSACTION_DATE
End Property

Public Property Get TRANSACTION_DATE() As Date
    TRANSACTION_DATE = tTRANSACTION_DATE
End Property

Public Property Let TRANSACTION_DATE(ByVal newTRANSACTION_DATE As Date)
    tTRANSACTION_DATE = CDate(Format((newTRANSACTION_DATE), "m / d / yyyy"))
End Property

What am I doing incorrectly?

Erik A
  • 31,639
  • 12
  • 42
  • 67
jcrizk
  • 605
  • 5
  • 15

1 Answers1

5
Public Property Get TRANSACTION_DATE() As Date
End Property

You can't have an underscore in a public interface member name in VBA, because then you get this:

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date

And VBA gets confused with the two underscores, it was only expecting one; in VBA a member that implements an interface member (or handles an event source's events) would be a private method named [Source]_[MemberName]: the _ underscore character has a syntactical meaning in an interface member's signature, it should be used carefully if at all, at least in any class that means to be implemented by others.

Rename your the property to PascalCase TransactionDate, and the problem goes away:

Public Property Get TransactionDate() As Date
End Property
Private Property Get ITransactionRecord_TransactionDate() As Date
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235