Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    42

    Unanswered: wrong number of arguments

    Can you help me? I get the error wrong type of arguments in my function as follows
    Private Sub Command0_Click()
    Call ANewDBWithPass("c:\BE\Lest", "secret")
    End Sub

    Function ANewDBWithPass(ByVal tName As String) '// adds the current date to the name of the database
    Dim wsp As Workspace
    Dim db2 As Database
    Set wsp = DBEngine.Workspaces(0)
    If Right(tName, 4) = ".mdb" Then
    ' Remove .mdb from the name
    tName = Left(tName, Len(tName) - 4)
    End If
    ' Add date and extension
    tName = tName & Format(Date, "dd-mm-yyyy") & ".mdb"
    ' Create database
    ',Set db2 = wsp.CreateDatabase(tName, dbLangGeneral)
    Set db2 = wsp.CreateDatabase(tName, dbLangGeneral & ";pwd=" & strPassword)
    db2.Close
    End Function

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Code:
    Call ANewDBWithPass("c:\BE\Lest", "secret")
    Has TWO arguments, but the function has just one.

    Start with the line

    Code:
    Function ANewDBWithPass(ByVal tName As String)
    and change it to

    Code:
    Function ANewDBWithPass(ByVal tName As String, strPassword as String)
    That should get you past the current error.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Mar 2006
    Posts
    42

    Thank you !

    Thank you so much !

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You're welcome
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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