Results 1 to 2 of 2
  1. #1
    GeorgeBrown is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011

    Compile error: code or function not defined

    I keep getting Compile error: code or function not defined. can someone review this code and tell me what is wrong
    The arrow is pointing to error being in Public sub open command

    Option Compare Database

    Option Explicit

    Public Sub OpenAppointmentForm(vTime As Date, vOffset As Long)

    'Opens Appointment form
    'Entry (vTime) = Time slot for selected row (06:30, 07:00, etc)
    ' (vOffSet) = No of days offset from Sunday (Sun = 0, Mon = 1, Tue = 2, etc)
    'Exit Appointment form displayed

    Dim vDateTime As Date

    vDateTime = Parent!txtDate & " " & vTime 'and fetch date and time of selected slot
    DoCmd.OpenForm "frmAppointment", , , , , acDialog, vDateTime + vOffset _
    & "," & Parent!cboCustomerId 'open frmAppointment form to add or amend appointment
    If gDummy = 0 Then Exit Sub 'abort if user cancels
    ShowAppointments Parent.cboCustomerId, Parent.txtDate 'refresh display if user changes an appt

    End Sub

    Private Sub Day1_Click()
    OpenAppointmentForm Me.TimeSlot, 0
    End Sub

    Private Sub Day2_Click()
    OpenAppointmentForm Me.TimeSlot, 1
    End Sub

    Private Sub Day3_Click()
    OpenAppointmentForm Me.TimeSlot, 2
    End Sub

    Private Sub Day4_Click()
    OpenAppointmentForm Me.TimeSlot, 3
    End Sub

    Private Sub Day5_Click()
    OpenAppointmentForm Me.TimeSlot, 4
    End Sub

    Private Sub Day6_Click()
    OpenAppointmentForm Me.TimeSlot, 5
    End Sub

    Private Sub Day7_Click()
    OpenAppointmentForm Me.TimeSlot, 6
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    8300' in the Colorado Rocky Mountains
    Try putting your OpenArgs argument in a String Variable first and the use a MsgBox to display it so you can see what your are getting.
    (RG for short) aka Allan Bunch Previous MS Access MVP - WinXP Pro, Win7 Pro Win10 Pro - acXP, ac07, ac10, ac13
    How to mark the thread as Solved!
    Teaching is not filling a bucket but lighting a fire.
    Borrowed quote..."Docendo discimus"

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

Similar Threads

  1. Compile error: Variable not defined
    By HarryScofs in forum Access
    Replies: 8
    Last Post: 07-25-2011, 09:06 AM
  2. Application-defined or object-defined error
    By hawkins in forum Access
    Replies: 6
    Last Post: 07-01-2011, 01:57 PM
  3. Compile error. Sub of function not defined
    By plavookins in forum Reports
    Replies: 7
    Last Post: 04-22-2011, 10:15 AM
  4. Replies: 1
    Last Post: 02-22-2011, 06:10 AM
  5. Replies: 23
    Last Post: 03-26-2009, 06:50 PM

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 - Senior Forums