Access 2007 Sql statement help :)

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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
 

OBP

Joined
Mar 8, 2005
Messages
19,896
Why not just enter the data directly in to the table using VBA?
 

OBP

Joined
Mar 8, 2005
Messages
19,896
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top