Compile error: Method or data member not found
I cant figure out why I am getting this error. Any ideas? Thanks
I cant figure out why I am getting this error. Any ideas? Thanks
Code:
Option Compare Database
Option Explicit
Dim intItems As Integer
Dim strName() As String, datBirthDate() As Date, intAge() As Integer
Private Sub Form_Load()
intItems = Val(InputBox("How many names do you have?", "Name List"))
Do While intItems <= 0
MsgBox "Please provide a positive numeric value.", vbCritical, "Data Required"
intItems = Val(InputBox("How many names do you have?", "Name List"))
Loop
ReDim strName(intItems - 1), datBirthDate(intItems - 1), intAge(intItems - 1)
Call Status
End Sub
Private Sub Status()
Dim intI As Integer, intCount As Integer
For intI = 0 To UBound(strName)
If strName(intI) <> "" Then
intCount = intCount + 1
End If
Next intI
[B] Me.lblStatus.[U]Caption[/U] = intCount & " names in your list of " & intItems & "are filled."[/B]
End Sub
Private Sub cmdAddToList_Click()
Dim intI As Integer
If IsNull(Me.txtName.Value) Or IsDate(Me.txtBirthDate.Value) = False Then
MsgBox "There must be correct values for both Name and birthdate.", _
vbCritical, "Data Entry Error"
Else
If strName(intItems - 1) <> "" Then
MsgBox "Sorry, no room!"
Me.txtName.Value = Null
Me.txtBirthDate = Null
Else
For intI = 0 To intItems - 1
If strName(intI) = "" Then
strName(intI) = Me.txtName.Value
datBirthDate(intI) = Me.txtBirthDate.Value
intAge(intI) = GetAge(Me.txtBirthDate.Value)
Me.txtName.Value = Null
Me.txtBirthDate.Value = Null
Exit For
End If
Next
End If
End If
Call Status
End Sub
Private Function GetAge(datDateOfBirth As Date) As Integer
Dim intFactorBDay As Integer
If Date < DateSerial(Year(Now), Month(datDateOfBirth), Day(datDateOfBirth)) Then
intFactorBDay = -1
End If
GetAge = DateDiff("yyyy", datDateOfBirth, Date) + intFactorBDay
End Function
Private Sub cmdClearList_Click()
ReDim strName(intItems - 1), datBirthDate(intItems - 1), intAge(intItems - 1)
Me.lblOutPut.Caption = ""
Call Status
End Sub
Private Sub cmdDisplayList_Click()
Dim intI As Integer, strOutPut As String
If strName(0) = "" Then
MsgBox "Nothing to display", vbInformation, "No Data"
Me.txtName.Value = Null
Me.txtBirthDate.Value = Null
Else
For intI = 0 To UBound(strName)
If strName(intI) <> "" Then
strOutPut = strOutPut & strName(intI) & " " & _
datBirthDate(intI) & " " & intAge(intI) & vbCrLf
End If
Next intI
Me.lblOutPut.Caption = strOutPut
Me.txtName.Value = Null
Me.txtBirthDate.Value = Null
End If
End Sub
Private Sub cmdNewList_Click()
Me.lblStatus.Caption = ""
Me.lblOutPut.Caption = ""
Call Form_Load
End Sub
Last edited: