Results 1 to 3 of 3
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    simple syntaq query ?

    I'm getting a '3061: Too few parameters error. Expected 1;
    ...and am just stuck;

    would someone have a moment to look over my shoulder (PLZ)
    with thnx in advance,
    m.



    Code:
        ' assign value to any existing records
        Dim vTableName As String
        Dim vFieldName As String
        vTableName = "tbeFixtureTypeDetails"
        vFieldName = "FixtComplete" 'dbInteger
        Set gsDbs = CurrentDb
    
        gsSQL = "UPDATE " & vTableName & " " _
            & "SET " & vFieldName & " = 0 " _
            & "WHERE " & vFieldName & " IS NULL;"
    
        gsDbs.Execute (gsSQL), dbFailOnError

  2. #2
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is how I would write it. You can comment out the debug statement - it is to check the SQL is formed correctly
    Code:
    Option Compare Database    '<<-- these two lines should be at the top of every module
    Option Explicit            '<<-- these two lines should be at the top of every module
    
    Public Sub test()
     ' assign value to any existing records
     
        Dim gsDbs As DAO.Database
        Dim gsSQL As String
        Dim vTableName As String
        Dim vFieldName As String
        
        Set gsDbs = CurrentDb
        
        vTableName = "tbeFixtureTypeDetails"
        vFieldName = "FixtComplete" 'dbInteger
    
        gsSQL = "UPDATE " & vTableName
        gsSQL = gsSQL & " SET " & vFieldName & " = 0"
        gsSQL = gsSQL & " WHERE " & vFieldName & " IS NULL;"
    
    Debug.Print gsSQL
    
    'Un-comment the following line when SQL is correct.
         '    gsDbs.Execute (gsSQL), dbFailOnError    
        
     'clean up
        Set gsDbs = Nothing
    End Sub
    Copy the SQL from the immediate window and paste into a query to test the SQL. It works for me.....

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Are you sure that your table and field names are spelled correctly in code? F'rinstance your table name is "tbeFixtureTypeDetails" and not tblFixtureTypeDetails?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 10
    Last Post: 03-15-2020, 01:46 AM
  2. Replies: 8
    Last Post: 10-17-2018, 11:52 AM
  3. Replies: 2
    Last Post: 11-10-2017, 07:52 PM
  4. Replies: 8
    Last Post: 03-16-2016, 10:11 AM
  5. Need Help with a very simple query
    By bikerguy06 in forum Queries
    Replies: 3
    Last Post: 06-08-2009, 08:43 PM

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