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

    Compile error - ambiguous name detected error

    Good Morning.



    The last couple of days I have been getting an Compile error, Ambiguous name detected: gDummy error. I never changed anything in the code so I am not sure what prompted this problem.

    This line of code is high lighted in yellow Public Sub OpenAppointmentForm(vDate As Date) and the word gDummy in this line is high lighted in blue. I use Access 2016.

    I also note that the below code is in Code tags but to me it looks like it is not. I apologize if it looks the same to you.

    Thanks Cheeco


    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub cmdDay_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        OpenDayCalendar X                           'switch to Daily mode
    End Sub
    Private Sub cmdWeekNo_Click()
    'Switch calendar mode to Weekly for selected date
    'Entry  (Me.Day1Date) holds date to be displayed
    'Exit   Calendar changed to Weekly mode for selected date
        Me.Parent!txtCurrentDate = Me.Day1Date  'set Current Date to Monday of current week
        Me.Parent!txtMode = 2                   'change mode in parent form
        CheckMode Me.Parent                     'Run CheckMode subroutine in parent form    ###
    End Sub
    Private Sub Day1Data_Click()
        Parent!txtCurrentDate = Me.Day1Date         'set current date when user clicks on a date field
        Me.Day1Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day1Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day1Date             'open Appointment form when user double clicks cell
    End Sub
    Private Sub Day1Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day1Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day2Data_Click()
        Parent!txtCurrentDate = Me.Day2Date
        Me.Day2Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day2Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day2Date
    End Sub
    Private Sub Day2Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day2Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day3Data_Click()
        Parent!txtCurrentDate = Me.Day3Date
        Me.Day3Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day3Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day3Date
    End Sub
    Private Sub Day3Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day3Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day4Data_Click()
        Parent!txtCurrentDate = Me.Day4Date
        Me.Day4Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day4Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day4Date
    End Sub
    Private Sub Day4Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day4Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day5Data_Click()
        Parent!txtCurrentDate = Me.Day5Date
        Me.Day5Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day5Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day5Date
    End Sub
    Private Sub Day5Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day5Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day6Data_Click()
        Parent!txtCurrentDate = Me.Day6Date
        Me.Day6Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day6Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day6Date
    End Sub
    Private Sub Day6Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day6Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Private Sub Day7Data_Click()
        Parent!txtCurrentDate = Me.Day7Date
        Me.Day7Data.Requery                         'set field to edit mode to enable arrow keys
    End Sub
    Private Sub Day7Data_DblClick(Cancel As Integer)
        OpenAppointmentForm Me.Day7Date
    End Sub
    Private Sub Day7Data_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then                                   'if ENTER key pressed then
            If conEnterKey = 0 Then OpenAppointmentForm Me.Day7Date     'open Appointment form for current date
            KeyCode = 0                                                 'disable key code to prevent focus moving to next cell
        End If
    End Sub
    Public Sub OpenAppointmentForm(vDate As Date)
    
    'Opens Appointment Schedule form when user double clicks an date field
    'Entry  (vDate) holds date of selected cell
    'Exit   Appointment form displayed and new appointments displayed when form closed
        DoCmd.OpenForm "frmCalendarAppt", , , , , acDialog, vDate + conFirstTime   'open form to add or amend appointment (use 08:00 as default time here)
        If gDummy = 1 Then                                                      'if any appt changed or added or deleted then
            ShowMonthAppts Parent.txtDate                                       'update amended calendar
            Parent.frmCalendarMonth.Requery                                     'and refresh subform
        End If
    End Sub
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        On Error Resume Next                        'ignore error if user tries to move to prev or next record that does not exist
        
        Select Case KeyCode                         'check Keycode
            Case vbKeyDown                          'if Down arrow then
                DoCmd.GoToRecord , , acNext         'go to next record
                KeyCode = 0
            Case vbKeyUp                            'if Up arrow then
                DoCmd.GoToRecord , , acPrevious     'go to prev record
                KeyCode = 0
        End Select
        Exit Sub
        
    ErrorCode:
        MsgBox Err.Description
    End Sub
    Private Sub Form_Open(Cancel As Integer)
    'Change back color of Conditional Format Condition (1) to light grey color
    Dim vCount As Long
    Dim vBool As Boolean
    'Update CF expression for field Day1Data with time slots to show in white and grey
        If conMonthHide = 1 Then vBool = False Else vBool = True
        For vCount = 1 To 7                                                             'for each day field on form
            Me("Day" & vCount & "Data").FormatConditions(1).BackColor = conLightGrey    'and change back color of Day-n-Data to light grey color
            Me("Day" & vCount & "Date").FormatConditions(1).BackColor = conLightGrey    'and change back color of Day-n-Date to light grey color
            Me("Day" & vCount & "Data").FormatConditions(1).Enabled = vBool             'enable/disable edit option if conMonthHide option = 0/1
        Next
    End Sub
    Public Sub OpenDayCalendar(vX As Single)
    'Switch calendar mode to Daily for selected date
    'Entry  (vX) X co-ords of mouse on hidden button
    'Exit   Calendar changed to Daily mode for selected date
        Me.Parent!txtCurrentDate = Me.Day1Date + (vX \ Me.Day1Date.Width)   'set Current Date on parent form
        Me.Parent!txtMode = 3                                               'change mode in parent form
        CheckMode Me.Parent                                                 'Run CheckMode subroutine in parent form    ###
    End Sub
    Last edited by orange; 04-21-2016 at 07:01 AM. Reason: adjusted bracket of code tag

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    What is gDummy, and where is it declared? It has to be declared somewhere as Public, because you are using Option Explicit but you are not getting the undeclared variable error.

  3. #3
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Ambigious name error

    Could someone have a look at this appointment calendar I found some. Cant remember where. It is constantly giving me gDummy error. Iget it working then for some reason it starts again with the error.
    It has to be something simple.
    Attached Files Attached Files

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I took a look, and I can't find an error with gDummy - it compiles fine, and gDummy is declared as public in a code module as it needs to be.

    That is in A2000 - maybe A2016 has an issue I don't know about. Did you try doing an explicit compile, i.e. opening any code module, and then doing Debug - Compile?

    Maybe you could try converting the .mdb to .accdb - maybe A2016 has problems with the older format.

    Beyond that, I dont see anything wrong. (it's a neat app, BTW)

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

Similar Threads

  1. Replies: 11
    Last Post: 06-04-2014, 10:58 AM
  2. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  5. Compile Error - Ambiguous Name ???
    By jacek.w.bak in forum Reports
    Replies: 1
    Last Post: 07-07-2011, 09:25 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