Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: ambigous name

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    First time trying to write a frame with option buttons, keep getting error ambigous name. What I have is
    Private Sub optSize_Click(Index As Integer)

    This is the first line of all 3 click buttons. New at this,I cant figure out what is wrong. Thx Dan

  2. #2
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    83,653
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    6 Thread(s)

    Default

    On 2002-03-23 11:08, dantb wrote:
    First time trying to write a frame with option buttons, keep getting error ambigous name. What I have is
    Private Sub optSize_Click(Index As Integer)

    This is the first line of all 3 click buttons. New at this,I cant figure out what is wrong. Thx Dan
    Just guessing: Index is a reserved word in VB, so i or idx should work.


  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    HI

    To add to Aladins comments

    Its just VBA clashes with what ever.

    Fix:

    Simple change the Sub name to something else, i try to keep simple...

    BTW the Sub name and the module name can not be the same this will error ... just in case


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Still trying, very much a beginer and trying to learn from a workbook. This is what I have.

    Option Explicit
    Dim PizzaSize As String
    Dim PizzaCrust As String
    Dim PizzaWhere As String


    Private Sub Form_Load()
    'Initialize pizza parameters
    PizzaSize = "Small"
    PizzaCrust = "Thin Crust"
    PizzaWhere = "Eat In"
    End Sub

    Private Sub optSize_Click(Index As Integer)
    'Read pizza size
    PizzaSize = optSize(Index).Caption
    End Sub

  5. #5
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This isn't done in VBA right ? it looks like VB, but not VBA...
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  6. #6
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Im in excels 2000 which comes with vba, its probaly not the full blown version

  7. #7
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This just doesn't like VBA

    Private Sub Form_Load()
    'Initialize pizza parameters
    PizzaSize = "Small"
    PizzaCrust = "Thin Crust"
    PizzaWhere = "Eat In"
    End Sub

    Private Sub optSize_Click(Index As Integer)
    'Read pizza size
    PizzaSize = optSize(Index).Caption
    End Sub
    Why ? well, in VBA you have Userforms, not forms, they don't have a Load event, they have an Initialize event. You can't (Directly) have array of controls (the optSize looks like OptionButtons).
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  8. #8
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    the project is under a user form, The opsize is a text box, the codes I copyed, came directely out of my workbook. dont know if where it said (index) is looking for a number or what. Just kind of lost.

  9. #9
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Yes, it is looking for a number. Which in theory should represent the index number of the Text box that has been clicked.

    Are there any more TextBoxes in there ? I believe more than one have the same name, which would cause the Ambigous name error.
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  10. #10
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Yes I have three text boxs, which I tryed to name them the same name but it wouldnt let me. Wolking on that too !

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •