1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access 2007 Sql statement help :)

Discussion in 'Business Applications' started by zr3cool, Nov 7, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. zr3cool

    zr3cool Thread Starter

    Joined:
    Jun 11, 2010
    Messages:
    73
    Hello Everyone:

    I have the following sql statement:

    Dim strSQL As String
    strSQL = "INSERT INTO xxx(datefortask, datedue)SELECT datefortask, datedue FROM steps"
    DoCmd.RunSQL strSQL


    This works good, I just need my ID on xxx table to be the ID of the client that Im currently on. Also I have a field "Type" that i need it to equal "xxx".

    So basically on the xxx table I like to see datefortask, datedue, Id=(current clients ID), type="xxx"
    Please help..im not good at the where Clause.
    Thank you :DDD
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Why not just enter the data directly in to the table using VBA?
     
  3. zr3cool

    zr3cool Thread Starter

    Joined:
    Jun 11, 2010
    Messages:
    73
    thank you for your reply.
    I thought thats what I was doing.
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    This is how you open the table directly using a Recordset and add data to the table.
    On Error GoTo Err_Command2_Click

    Dim rs As Object
    Set rs = CurrentDb.OpenRecordset("xxx")
    rs.MoveLast
    rs.MoveFirst

    With rs
    .AddNew
    !ID = me.[client ID
    .Update
    .Bookmark = .LastModified
    End With
    rs.Close
    Set rs = Nothing

    Exit_Command2_Click:
    Exit Sub

    Err_Command2_Click:
    MsgBox Err.Description
    Resume Exit_Command2_Click

    You have to ensure the Name of the Table & fields are correctly spelt.
    If you prefer you can use where like this
    SQL = "SELECT Que_CallNumber.* " & _
    "FROM Que_CallNumber " & _
    "WHERE DealerCode = " & Me.Dealercode
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1025884

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice