Consulting

Results 1 to 3 of 3

Thread: VBA code

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Posts
    41
    Location

    VBA code

    The Following is giving too few arguments error:
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2


    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("SELECT EMAIL, NM FROM [Tbl_Personal] WHERE [NM]= BE")
    strPassword = rst("EMAIL")
    17 rst.Close
    18 CurrentDb.Close


    The table Tbl_Personal has 2 fields NM & EMAIL. BE is a string stored in NM.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Well I prefer to use a string variable to hold the SQL for the recordset.
    ie
    Dim rs As Object
    
      Dim SQL As String
    
      
    
       SQL = "SELECT Que_CallNumber.* " & _
    
        "FROM Que_CallNumber " & _
    
        "WHERE DealerCode = " & Me.Dealercode
    
        Set rs = CurrentDb.OpenRecordset(SQL)
    The other problem could be that it is not treating BE as a string and you may have to change it in to one using code like.
    "WHERE DealerCode = '" & Me.Dealercode & "'"

  3. #3
    VBAX Regular
    Joined
    Nov 2018
    Posts
    41
    Location
    Quote Originally Posted by OBP View Post
    Well I prefer to use a string variable to hold the SQL for the recordset.
    ie
    Dim rs As Object
    
      Dim SQL As String
    
      
    
       SQL = "SELECT Que_CallNumber.* " & _
    
        "FROM Que_CallNumber " & _
    
        "WHERE DealerCode = " & Me.Dealercode
    
        Set rs = CurrentDb.OpenRecordset(SQL)
    The other problem could be that it is not treating BE as a string and you may have to change it in to one using code like.
    "WHERE DealerCode = '" & Me.Dealercode & "'"

    Thanks a Lot!!! GOD BLESS YOU!!!

Tags for this Thread

Posting Permissions

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