Results 1 to 5 of 5
  1. #1
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155

    OpenRecordset method

    Function TOWARDS(CRNO As String)
    Dim dbsNorthwind As DAO.Database
    Dim rstEmployees As DAO.Recordset
    Dim strSQL As String
    Dim intI As Integer



    'On Error GoTo ErrorHandler

    Set dbsNorthwind = CurrentDb

    ' Open a recordset on all records from the Employees table that have
    ' a Null value in the ReportsTo field.
    ' strSQL = "SELECT ALLOCATION, AMOUNTs FROM [DEPARTMENT & ALLOCATION] WHERE [CR NO]= & [CRNO]"
    Set rstEmployees = dbsNorthwind.OpenRecordset("SELECT [ALLOCATION], [AMOUNTs] FROM [DEPARTMENT & ALLOCATION] WHERE [CR NO]=" & [CRNO])



    ' Return the Recordset
    TOWARDS = "DONE"
    End Function

    The command
    Set rstEmployees = dbsNorthwind.OpenRecordset("SELECT [ALLOCATION], [AMOUNTs] FROM [DEPARTMENT & ALLOCATION] WHERE [CR NO]=" & [CRNO])

    is giving Error 3061 :Too few Parameters. Expected1.




    WHAT TO DO?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Is [CR NO] a number type field?

    You have [CR NO] and [CRNO] - one has space a one doesn't. Is this correct?

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155
    Quote Originally Posted by June7 View Post
    Is [CR NO] a number type field?

    You have [CR NO] and [CRNO] - one has space a one doesn't. Is this correct?

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.


    [CR NO] is defined in table [DEPARTMENT & ALLOCATION] as Short Text.

    [CRNO] is a String parameter of Function TOWARDS(CRNO as String)

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    As CRNO is a text field, you need text delimiters in each place it is used

    Code:
    Where [CR NO]='" & CRNO & "'"
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155

    Thanks! It worked. God bless you.

    Quote Originally Posted by ridders52 View Post
    As CRNO is a text field, you need text delimiters in each place it is used

    Code:
    Where [CR NO]='" & CRNO & "'"


    Thanks! It worked. God bless you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-26-2017, 08:14 AM
  2. Set rst = qdf.OpenRecordset(dbOpenSnapshot)
    By malin7232 in forum Programming
    Replies: 2
    Last Post: 06-25-2017, 10:04 PM
  3. Replies: 6
    Last Post: 06-25-2016, 02:56 PM
  4. Too Few Parameters on .OpenRecordset()
    By Voodeux2014 in forum Forms
    Replies: 9
    Last Post: 01-28-2016, 04:45 PM
  5. OpenRecordset vs. Query
    By crispy-bacon in forum Programming
    Replies: 7
    Last Post: 07-04-2011, 09:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums