I have the below code in a macro. It is with an Access calender and appointment database. It works great but when I copy the tables and modules and so over to my database I get an error with lines Public Sub InitialiseTimesSlots(). This line is highlited in yellow. and the line rst.Edit the .Edit highlited in blue. The error is a Compile error Method or data member not found. How do I fix this problem? Thank-you Cheeco
Code:
End Sub
Public Sub InitialiseTimesSlots()
'Sets up the time slots in tblWeekData based on value of Constant conAltTimes
'Entry (conAltTimes) = 0 to show alternate time slots or 1 to show ALL time slots
' (conPeriod) = No of minutes for each time slot
' (tblWeekData) holds records (TimeSlots field holds times of time slots as all or alternate)
'Exit TimeSlots field updated with appropriate time values
Dim vTime As Date
Dim rst As Recordset
On Error GoTo ErrorCode
vTime = "00:00:00" 'init time
Set rst = CurrentDb.OpenRecordset("SELECT RowNo, TimeSlots FROM tblWeekData ORDER BY RowNo") 'open recordset for table
Do Until rst.EOF
rst.Edit 'edit record
If conAltTimes = 0 Then
If rst!RowNo Mod 2 = 1 Then rst!TimeSlots = TimeValue(vTime) Else rst!TimeSlots = Null 'set time value on alternate rows
Else
rst!TimeSlots = TimeValue(vTime) 'set time on every row
End If
rst.Update
vTime = DateAdd("n", conPeriod, vTime) 'inc time by conPeriod minutes
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Exit Sub
ErrorCode:
Beep
MsgBox Err.Description
End Sub
Public Sub CheckMode(frm As Object) '###
'Show calendar for selected month/week/day
'Entry (frm) = Reference object to calling form ###
On Error GoTo ErrorCode
frm.togMonth = False 'reset all toggle btns first
frm.togWeek = False
frm.togDay = False
Select Case frm.txtMode
Case 1
frm.togMonth = True 'activate toggle button
frm.tabCalendar = 0 'switch to tab 0 (Month)
frm.txtDate.Format = "mmmm yyyy"
frm.txtDate = DateSerial(year(frm.txtDate), month(frm.txtDate), 1) 'default to first day of current month
ShowMonthAppts frm.txtDate 'show appts for month
frm.frmCalendarMonth.Requery 'and refresh subform
frm.cmdNext.Caption = "&Next Month" 'update button captions & tool tips
frm.cmdPrev.Caption = "&Prev Month"
frm.cmdNext.ControlTipText = "Show next month's appointments"
frm.cmdPrev.ControlTipText = "Show previous month's appointments"
frm.cmdPrint.Enabled = True 'enable Print btn
Case 2 'switch to tab 1 (Week)
frm.togWeek = True 'activate toggle button
frm.tabCalendar = 1
frm.txtDate.Format = "Long Date" 'set header date format
frm.txtDate = frm.txtCurrentDate - Weekday(frm.txtCurrentDate, conFirstDay) + 1 'calc first Sunday on calendar
ShowWeekAppts frm.txtDate 'update weekly appts
frm.frmCalendarWeek.Requery 'and refresh subform
frm.frmCalendarWeek.SetFocus 'move focus to subform
frm.frmCalendarWeek!Day1Data.SetFocus 'and then to Day1Data field
frm.frmCalendarWeek.Form.SelTop = frm.frmCalendarWeek.Form.RecordsetClone.RecordCount 'set top row to last row first
frm.frmCalendarWeek.Form.SelTop = (((Hour(conTime) * 60) + Minute(conTime)) / conPeriod) + 1 'calc last row number from time value
frm.cmdClose.SetFocus 'move focus away from subform
frm.cmdNext.Caption = "&Next Week" 'update button captions & tool tips
frm.cmdPrev.Caption = "&Prev Week"
frm.cmdNext.ControlTipText = "Show next week's appointments"
frm.cmdPrev.ControlTipText = "Show previous week's appointments"
frm.cmdPrint.Enabled = False 'disable Print btn
Case 3 'switch to tab 2 (Day)
frm.togDay = True 'activate toggle button
frm.tabCalendar = 2
frm.txtDate.Format = "Long Date"
frm.txtDate = frm.txtCurrentDate 'set date to selected date
ShowDayAppts frm.txtDate 'update daily appts
frm.frmCalendarDay.Requery 'and refresh subform
frm.frmCalendarDay.SetFocus 'move focus to subform
frm.frmCalendarDay!Day1Data.SetFocus 'and then to Day1Data field
frm.frmCalendarDay.Form.SelTop = frm.frmCalendarDay.Form.RecordsetClone.RecordCount 'set top row to last row first
frm.frmCalendarDay.Form.SelTop = (((Hour(conTime) * 60) + Minute(conTime)) / conPeriod) + 1 'calc last row number from time value
frm.cmdClose.SetFocus 'move focus away from subform
frm.cmdNext.Caption = "&Next Day" 'update button captions & tool tips
frm.cmdPrev.Caption = "&Prev Day"
frm.cmdNext.ControlTipText = "Show next day's appointments"
frm.cmdPrev.ControlTipText = "Show previous day's appointments"
frm.cmdPrint.Enabled = False 'disable Print btn
End Select
Exit Sub
ErrorCode:
Beep
MsgBox Err.Description
End Sub