Results 1 to 6 of 6
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Another DCount

    I can't seem to fathom the quotes. I even went to Minty's link.


    Code:
    DCount("[strField1]","Table1","[StrField2]='" & [StrField2] & "' AND [StrField3]='" & [StrField3] & "' And [StrField1]='String' & " And ID < " & [ID]+1)

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    Code:
    DCount("[strField1]","Table1","[StrField2]='" & [StrField2] & "' AND [StrField3]='" & [StrField3] & "' And [StrField1]='String' And ID < " & [ID]+1)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    pbaldy,
    I get an error when I run this:
    Code:
    UPDATE Data SET Table1.NumSeq = DCount("[strField1]","Table1","[StrField2]='" & [StrField2] & "' AND [StrField3]='" & [StrField3] & "' And [StrField1]='String' And ID < " & [ID]+1)
    WHERE (((Data.[Row Type])="string"));
    It runs the query fine and errors out when it goes to write to the table.

    Error:
    MS Access didn't update # fields due to a type conversion failure, 0 record(s) due to key violations,
    0 record(s) due to lock violations, and
    0 record(s) due to validation rule violations.

    table1.StrField1 = Short Text
    table1.StrField2 = Short Text
    table1.StrField3 = Short Text
    table1.NumSeq = Number

    I made a smaller testdb:

    I know there is numerical sequence only in one of the fields, but this is how it gets exported from elsewhere and imported to mine. It still serves its purpose to uniquely identify the record.


    Attached Files Attached Files

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You had a space in the Platform_id field name. Try

    UPDATE Table1 SET Table1.NumSeq = DCount("[Row Type]","Table1","[Platform_id]='" & [Platform_id] & "' AND [Role / FE / Node Name]='" & [Role / FE / Node Name] & "' And [Row Type]='MEQUIP' And ID < " & [ID]+1)
    WHERE (((Table1.[Row Type])="MEQUIP"));

    We haven't broken you of the spaces and symbols by now?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks pbaldy, That did the trick. I think I had my eyes crossed running through this so many times, and missing a blank space every time....

    Appreciate it.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. DCount Help
    By mpaulbattle in forum Queries
    Replies: 3
    Last Post: 11-21-2016, 11:42 AM
  2. DCount help
    By McArthurGDM in forum Programming
    Replies: 6
    Last Post: 06-15-2015, 04:30 PM
  3. DCount
    By nsteenhaut in forum Queries
    Replies: 2
    Last Post: 10-04-2011, 05:00 PM
  4. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  5. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 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