Ambiguous name, ?

bpaquette

Registered User.
Local time
Today, 12:06
Joined
Aug 13, 2003
Messages
119
If i didn't shave my head, this would make me pull my hair out.

in one db, i have a module that defines a changeproperty function, and a form that calls it onclick. i don't think what it does is relevant.

anyway, in one database, it works fine.


i create another databse, copy the button code and the module, and try to run it, but i get an "ambiguous name" error on the changeproperty function call.

What could possibly be different between the two environments? all my references are congruent, if that matters.

any ideas?

thanks
bp
 
Have you hardcoded a control name in the function?

Can you post the line it zonks out on when you debug it?

???
ken
 
The code for the click function is below, the line it screws up at is:

ChangeProperty "AllowBypassKey", dbBoolean, True

Code:
Private Sub Command45_Click()

On Error GoTo Err_bDisableBypassKey_Click
    
    Dim strInput As String
    Dim strMsg As String
    
    Beep
    strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & "Please key the programmer's password to enable the Bypass Key."
    strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
    
    If strInput = "aimhighhooah" Then
       
        
        ChangeProperty "AllowBypassKey", dbBoolean, True
        Beep
        MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & "The Shift key will allow the users to bypass the startup options the next time the database is opened.", vbInformation, "Set Startup Properties"
    Else
   
        Beep
        ChangeProperty "AllowBypassKey", dbBoolean, False
       
        MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & "The Bypass Key was disabled." & vbCrLf & vbLf & "The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", vbCritical, "Invalid Password"
        Exit Sub
    End If
    
Exit_bDisableBypassKey_Click:
    Exit Sub
    
Err_bDisableBypassKey_Click:
    MsgBox "Runtime Error # " & Err.Number & vbCrLf & vbLf & Err.Description
    Resume Exit_bDisableBypassKey_Click
    
End Sub
 
That error usually means that you have used the same sub or function name more than once. Search your db for the function/sub name and I would bet [a nickle] that you will find it in more than one place in your db.
 
That was my initial guess, too. The thing is, this particular mdb only has one module and one form (and a table), and the form only has the code i posted earlier, and the module can be seen below. These bits of code were copied/pasted from another database where they worked flawlessly. Hopefully you can help ghudson; you wrote some of this code originally I believe :)


Code:
Option Compare Database

' *********** Code Start ***********
'This code was originally written by Michael Kaplan.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Michael Kaplan
'
Function ChangePropertyDdl(stPropName As String, _
 PropType As DAO.DataTypeEnum, vPropVal As Variant) _
 As Boolean
 ' Uses the DDL argument to create a property
 ' that only Admins can change.
 '
 ' Current CreateProperty listing in Access help
 ' is flawed in that anyone who can open the db
 ' can reset properties, such as AllowBypassKey
 '
    On Error GoTo ChangePropertyDdl_Err

    Dim db As DAO.Database
    Dim prp As DAO.Property

    Const conPropNotFoundError = 3270

    Set db = CurrentDb
    ' Assuming the current property was created without
    ' using the DDL argument. Delete it so we can
    ' recreate it properly
    db.Properties.Delete stPropName
    Set prp = db.CreateProperty(stPropName, _
     PropType, vPropVal, True)
    db.Properties.Append prp

    ' If we made it this far, it worked!
    ChangePropertyDdl = True

ChangePropertyDdl_Exit:
    Set prp = Nothing
    Set db = Nothing
    Exit Function

ChangePropertyDdl_Err:
    If Err.Number = conPropNotFoundError Then
        ' We can ignore when the prop does not exist
        Resume Next
    End If
    Resume ChangePropertyDdl_Exit
End Function

Function ChangeProperty(strPropName As String, _
 varPropType As Variant, varPropValue As Variant) As Integer
' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CreateProperty doesn't use the DDL
' argument
'
 Dim dbs As Database, prp As Property
 Const conPropNotFoundError = 3270

 Set dbs = CurrentDb
 On Error GoTo Change_Err
 dbs.Properties(strPropName) = varPropValue
 ChangeProperty = True

Change_Bye:
 Exit Function

Change_Err:
 If Err = conPropNotFoundError Then ' Property not found.
  Set prp = dbs.CreateProperty(strPropName, _
        varPropType, varPropValue)
  dbs.Properties.Append prp
  Resume Next
 Else
  ' Unknown error.
  ChangeProperty = False
  Resume Change_Bye
 End If
End Function
' *********** Code End ***********
 
if i am not mistaken, i remember someone mentioning a similar problem on this forum and the problem was with the copy/paste from one module to another. I didn't manage to find the thread to link you to it, not sure which keywords i should search for.
 
With that in mind, I deleted the module and then imported it (as opposed to copy/pasting). Still same error :\
 
i am sure that this problem has already been pointed out before on this forum. maybe the member who posted the solution, might reply to this thread or maybe give the link to the similar thread.
 
i don't know how, or why, but problem solved

all i did was close it and open it again.


ah, well, thanks everyone
 

Users who are viewing this thread

Back
Top Bottom