Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Compile error (2003)

    I've copied a module that someone created which automatically fills in fields. I'm getting a Complie error: Ambiguous name detected:g_intIndex
    The reference in the module is g_intIndex = 1. What do I need to change to get the module to work.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    Apparently g_intIndex has been defined more than once.

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    I've changed everything and when I run the form I get Syntax Error (missing operators) in Query Expression 'Customer Order No', but I'm not running a query?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    I don't think it is possible to help without having all relevant information or seeing the database.

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    I've managed to sort that problem, but now I've got an error when the modules run that says 'Too few parameters. Expected 2', but I don't know where to look

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    This usually means that SQL contains references to something that is not recognized. ADO and DAO work on a lower level than the Access interface; they don't "know" about Access forms.

    It's impossible to provide more help without having relevant information.

  7. #7
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    This is the code I'm running, if it helps.

    Option Compare Database
    Option Explicit

    Global f_intIndex As Integer

    Public Sub FillInFields2(strCof_NUMBER As String, _
    Optional intIndex As Integer = 1)
    On Error GoTo err_FillInFields2

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim intResponse As Integer


    Set db = CurrentDb
    strSQL = "SELECT Customer_Order_No " & _
    " FROM Table1 WHERE Cof_Number = '" & strCof_NUMBER & "'"
    Set rs = db.OpenRecordset(strSQL)
    If Not rs.BOF Then
    ' fill in fields on form
    Select Case intIndex
    Case 1
    Forms!CofC.[Cof NUMBER] = rs("Cof_NUMBER")


    Case Else
    MsgBox "You have not entered a valid index number."
    End Select
    Else
    ' insert new data into CertNos table
    intResponse = MsgBox("Do you wish to add Cof No " & strCof_NUMBER & " to the table ?", vbOKCancel)
    If intResponse = vbOK Then
    MsgBox "Please enter values for the next three fields and click the 'Add' button."
    Forms!CofC.cmdAdd.Visible = True
    End If
    End If
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

    exit_FillInFields2:
    Exit Sub

    err_FillInFields2:
    MsgBox Err.Description
    Resume exit_FillInFields2

    End Sub

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    If Table1 is the same table as in the thread Save form data (2003), the field names are Customer Order No and Cof NUMBER (without underscores). To include names with spaces in an SQL string, you must put them between square brackets [ ]:
    <code>
    strSQL = "SELECT [Customer Order No] " & _
    " FROM Table1 WHERE [Cof Number] = '" & strCof_NUMBER & "'"</code>

  9. #9
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    Changed that. Now getting 'Item not found in this collection'. If that means in table1, the Cof Number I'm typing in is there.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    Have you thought of changing the line

    Forms!CofC.[Cof NUMBER] = rs("Cof_NUMBER")

    for consistency?

  11. #11
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    Tried putting underscore under both or square brackets round both, and I still get the message.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    Did you try

    Forms!CofC![Cof NUMBER] = rs("[Cof NUMBER]")

  13. #13
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    Yes, tried that. If I do put a wrong number in, another module asks me if I want to add it to the list, so that's working.

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (2003)

    Does this mean your problem is solved?

  15. #15
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Compile error (2003)

    No. If I put a number in that I know is in the table, I still get the error message.

Page 1 of 2 12 LastLast

Posting Permissions

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