Results 1 to 5 of 5
  1. #1
    WhiskyLima is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2013
    Location
    UK
    Posts
    32

    My First attempt at SQL

    Hi guys. Im working with a database in access and have now found that I cannot do certain things without SQL so im trying my best. I basically I want to amend a field so that it includes the word 'credited' at the end. For example, if the value was originally 'Deposit Invoice', I would like to change it to 'Deposit Invoice Credited'.



    The reason Im using SQL is because this is initiated from a different record from the same table with the use of a button. Anyway. I have this code:
    Code:
    CurrentDb.Execute "UPDATE Invoices SET InvoiceType='Credited' WHERE InvoiceNumber=" & YesNo
    As you can see this will change the field to Credited but will not amend credited to the existing contents of the field.

    I hope this makes more sense to you than it does to me. As always I really do appreciate any help I can get so many thanks in advance.

  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,518
    I assume that's not the actual code, but to add that to the end:


    CurrentDb.Execute "UPDATE Invoices SET InvoiceType=InvoiceType & 'Credited' WHERE InvoiceNumber=" & YesNo
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    WhiskyLima is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2013
    Location
    UK
    Posts
    32
    Yeah this is just the line I was after working out, everything else is in place. That works perfectly and now I feel a little dumb. I have been using this exact same method time and time again in VBA and just assumed it wouldn't work here.

    Thank you so much for your help!

  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,518
    No problem! I actually mentioned that because it didn't seem "YesNo" would hold an invoice number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    WhiskyLima is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2013
    Location
    UK
    Posts
    32
    yeah, YesNo is just a question presented to the user to ask which invoice number the credit is related it.

    Many Thanks once again!

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

Similar Threads

  1. first attempt to build a database but need alot of help !
    By komet122 in forum Database Design
    Replies: 3
    Last Post: 03-07-2013, 12:09 PM
  2. Building my Own Collection(s) - Attempt #2!
    By Rawb in forum Programming
    Replies: 2
    Last Post: 12-18-2012, 08:25 AM
  3. Replies: 7
    Last Post: 08-10-2012, 03:09 PM
  4. Failed attempt at concetenation
    By snowboarder234 in forum Queries
    Replies: 2
    Last Post: 07-12-2012, 09:02 AM
  5. First Timer attempt at Project List
    By SHogan in forum Reports
    Replies: 3
    Last Post: 02-06-2012, 10:33 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