Results 1 to 3 of 3
  1. #1
    TamworthBob is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2020
    Posts
    7

    Insert Into statement

    Hi
    Is there a way to get the following to insert the value of the Ints? (eg IntSurname) I want say "Robinson" not IntSurname

    et dbs = OpenDatabase("S:\Data\WirelessComponentsData.accdb ")

    ' Create a new record in the DistributorContacts table.
    dbs.Execute " INSERT INTO tblDistributorContacts " _
    & "(DistributorContactFirstName,DistributorContactSu rname, Phone, Mobile) VALUES " _
    & "('IntFirstName', 'IntSurname', 'IntPhone', 'IntMobile');"

    dbs.Close


    Thanks
    Bob

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Concatenate variables.
    Code:
    dbs.Execute "INSERT INTO tblDistributorContacts " _
    & "(DistributorContactFirstName, DistributorContactSurname, Phone, Mobile) VALUES ('" _
    & IntFirstName & "', '" & IntSurname & "', '" & IntPhone & "', '" & IntMobile & "')"
    
    Why have you declared string variables with Int prefix?
    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
    TamworthBob is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2020
    Posts
    7
    Thanks, works great
    I guess I have got a little lazy with my declarations...thanks for the kick in the butt
    Bob

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

Similar Threads

  1. Replies: 7
    Last Post: 05-10-2019, 10:40 PM
  2. Insert into with a WHERE statement
    By hazeleyre23 in forum Access
    Replies: 10
    Last Post: 04-06-2016, 08:28 AM
  3. INSERT statement
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 03-29-2013, 12:53 PM
  4. Insert Into statement
    By TimMoffy in forum Programming
    Replies: 7
    Last Post: 07-13-2012, 07:10 AM
  5. Insert statement
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 08-19-2011, 02:20 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