Results 1 to 2 of 2
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Error with Access calender and appointment database

    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

    Last edited by CHEECO; 04-17-2016 at 11:17 AM. Reason: ADDION

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Check your references in the vb editor. You likely do not have a reference to DAO since you started out with a new db. Maybe go back to the old one and see what references you had, decide if they're all required, and reference them in the new db. In coding, always explicitly define your objects unless you have a specific need for late binding: Dim rst As DAO.Recordset Hopefully, you also see OPTION EXPLICIT at the top of every module. Both of these factors are important if you're going to be a good code writer. Google late vs early binding and Option Explicit if you are not familiar with these concepts.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recurring Scheduling/Appointment Database
    By pandor4 in forum Sample Databases
    Replies: 3
    Last Post: 07-16-2014, 04:50 PM
  2. appointment Sample Database
    By AzizSader in forum Forms
    Replies: 2
    Last Post: 05-31-2014, 06:58 AM
  3. Replies: 2
    Last Post: 04-15-2013, 04:00 AM
  4. Access 2003 Calender Sub Form and PopUp
    By pkstormy in forum Code Repository
    Replies: 1
    Last Post: 07-29-2012, 10:50 AM
  5. Appointment Booking Database
    By richie2837 in forum Access
    Replies: 1
    Last Post: 07-16-2011, 01:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums