I have a Calendar application (found it here and modified it for my use) that when I import the tables, forms and modules into a new database it starts giving me a "Compile error: Method or data member not found" Here is the code:
Option Compare Database
Option Explicit
Public db As Database
Public rs As Recordset
Private mCal As Form
Function Cal(mo, yr)
Dim i As Integer
Dim DayOne, WorkDate, Offset
Set mCal = Forms!frmCalender
mCal!month.SetFocus
mo = mCal!month
yr = mCal!year
For i = 1 To 37
mCal("Day" & i + Offset).Visible = False
mCal("Text" & i + Offset).Visible = False
mCal("date" & i + Offset) = Null
mCal("day" & i + Offset) = Null
Next
DayOne = DateValue(mo & "/1/" & yr)
WorkDate = DayOne
Offset = WeekDay(DayOne) - 1
For i = 1 To LenMonth(DayOne)
mCal("Day" & i + Offset).Visible = True
mCal("Text" & i + Offset).Visible = True
mCal("date" & i + Offset) = WorkDate
mCal("day" & i + Offset) = i
WorkDate = WorkDate + 1
Next
Call PutInData
End Function
Function LenMonth(d)
Dim Start, Finish
Start = DateValue(month(d) & "/1/" & year(d))
Finish = DateAdd("m", 1, Start)
LenMonth = Finish - Start
End Function
Function SendToInputBox(mynum)
Dim strDate As String
strDate = Format(mCal("Date" & mynum), "dddd mmmm d, yyyy")
DoCmd.OpenForm "frmInputBox"
With Forms!frmInputBox
!InputDay = mynum
!InputDate = mCal("Date" & mynum)
!InputFor = strDate
!original_text = mCal("Text" & mynum)
!InputText = mCal("Text" & mynum)
!InputText.SetFocus
SendKeys "{F2}^{HOME}", False
End With
End Function
Public Sub PutInData()
Dim strSQL As String
Dim i As Integer
For i = 1 To 37
mCal("text" & i) = Null
Next i
strSQL = "SELECT * FROM [tblInput] WHERE ((MONTH(InputDate) = " & mCal!month & " AND YEAR(InputDate) = " & mCal!year & ")) ORDER BY InputDate;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
For i = 1 To 37
If IsDate(mCal("date" & i)) Then
rs.FindFirst "inputdate=#" & mCal("date" & i) & "#"
If Not rs.NoMatch Then
mCal("text" & i) = rs!InputText
End If
End If
Next i
End If
End Sub
The red colored area is highlighted in Yellow when it debugs and the green area is highlighted in blue.
John Green
Option Compare Database
Option Explicit
Public db As Database
Public rs As Recordset
Private mCal As Form
Function Cal(mo, yr)
Dim i As Integer
Dim DayOne, WorkDate, Offset
Set mCal = Forms!frmCalender
mCal!month.SetFocus
mo = mCal!month
yr = mCal!year
For i = 1 To 37
mCal("Day" & i + Offset).Visible = False
mCal("Text" & i + Offset).Visible = False
mCal("date" & i + Offset) = Null
mCal("day" & i + Offset) = Null
Next
DayOne = DateValue(mo & "/1/" & yr)
WorkDate = DayOne
Offset = WeekDay(DayOne) - 1
For i = 1 To LenMonth(DayOne)
mCal("Day" & i + Offset).Visible = True
mCal("Text" & i + Offset).Visible = True
mCal("date" & i + Offset) = WorkDate
mCal("day" & i + Offset) = i
WorkDate = WorkDate + 1
Next
Call PutInData
End Function
Function LenMonth(d)
Dim Start, Finish
Start = DateValue(month(d) & "/1/" & year(d))
Finish = DateAdd("m", 1, Start)
LenMonth = Finish - Start
End Function
Function SendToInputBox(mynum)
Dim strDate As String
strDate = Format(mCal("Date" & mynum), "dddd mmmm d, yyyy")
DoCmd.OpenForm "frmInputBox"
With Forms!frmInputBox
!InputDay = mynum
!InputDate = mCal("Date" & mynum)
!InputFor = strDate
!original_text = mCal("Text" & mynum)
!InputText = mCal("Text" & mynum)
!InputText.SetFocus
SendKeys "{F2}^{HOME}", False
End With
End Function
Public Sub PutInData()
Dim strSQL As String
Dim i As Integer
For i = 1 To 37
mCal("text" & i) = Null
Next i
strSQL = "SELECT * FROM [tblInput] WHERE ((MONTH(InputDate) = " & mCal!month & " AND YEAR(InputDate) = " & mCal!year & ")) ORDER BY InputDate;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
For i = 1 To 37
If IsDate(mCal("date" & i)) Then
rs.FindFirst "inputdate=#" & mCal("date" & i) & "#"
If Not rs.NoMatch Then
mCal("text" & i) = rs!InputText
End If
End If
Next i
End If
End Sub
The red colored area is highlighted in Yellow when it debugs and the green area is highlighted in blue.
John Green