Results 1 to 6 of 6

Thread: Access Queries

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    Access Queries

    I have a query which creates me a table from another depending on a value fed into it called the 'Reference' field e.g. containing: BDF/739/2005/0 (x number of rows)

    What I now want to do is update that reference from BDF/739/2005/0 to BDF/739/2005/1 so that it adds a 1 to the end or a 2 or a 3 depending what the original end number was. Is there an SQL update query which can manipulate strings like this?

    Any help on this would be much appreciated

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access Queries

    You could try the following if the reference starts at 0... if not then change the last digit to reflect, removing would set it to 1..

    NewRef: Left([Reference],Len([reference])-1) & (DCount("RecordNumb","tblTest","RecordNumb<" & [Recordnumb])+1)-1
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    Re: Access Queries

    not quite sure what you mean as Reference may be :

    BDF/739/2005/1
    BDF/739/2005/2
    BDF/739/2005/3 etc.

    Sorry for being simple but I dont understand how you used "RecordNumb" in the DCount function? Can you please explain it more?

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access Queries

    Should of Explained.. the Dcount part of the SQL takes the primarykey (needs to be sorted in ascending order) and creates a sequence counter, as explained in your earlier post..

    It's just a field name, and will need to be changed to reflect your own primary key in the table..

    Actually looking back at your problem.. I'm gonna need to change it slightly.. BRB
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access Queries

    Here you go this is a string manipulation formula you can use..

    NewRef: Left([Reference],InStrRev([Reference],"/")) & CLng(Mid([Reference],InStrRev([Reference],"/")+1))+1
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    Re: Access Queries

    Thanks I'll try that now

Posting Permissions

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



Click Here to Expand Forum to Full Width