Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append a DateStamp in Query 1

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
US
I have a snippet of code I wrote:
Code:
sqlString = "INSERT INTO tblMappedAssets " _
   & "( AssetID, [File Name], [Software Name], Version, Family, Category, Publisher, Description)" _
   & "SELECT tempImport." & Me.cboAsset.Value & " AS [Asset ID], " _
   & "tempImport." & Me.cboFileNAme.Value & " AS [File Name], " _
   & "tempImport." & Me.cboSoftware.Value & " AS [Software Name], " _
   & "tempImport." & Me.cboVersion.Value & " AS Version, " _
   & "tempImport." & Me.cboFamily.Value & " AS Family, " _
   & "tempImport." & Me.cboCategory.Value & " AS Category, " _
   & "tempImport." & Me.cboPublisher.Value & " AS Publisher, " _
   & "tempImport." & Me.cboDesc.Value & " AS Description " _
   & " FROM tempImport;"    [red]'DateTime to be defined[/red]
    Debug.Print sqlString    
    DoCmd.RunSQL sqlString
that produces a query string:
Code:
INSERT INTO tblMappedAssets ( AssetID, [File Name], [Software Name], Version, Family, Category, Publisher, Description)SELECT tempImport.ASSET_ID AS [Asset ID], tempImport.PULSE AS [File Name], tempImport.PRODUCT_ID AS [Software Name], tempImport.VERSION AS Version, tempImport.FAMILY AS Family, tempImport.CATEGORY AS Category, tempImport.PUBLISHER AS Publisher, tempImport.AMGUID AS Description  
FROM tempImport;
My "tblMappedAssets" table also has fields for DateStamp and UserID. I can get these from NOW() and capturing the logged on user; but I do not know the syntax to add them to my query.

Thanks!


Alan

 
You could add the timestamp a number of ways, including just adding the function Now() to your query. like
Code:
..._
& "Now() as DateStamp, " _
...
or simply by making the default value for DateStamp (in the table) = NOW().

If the user is logged into your database, you probably have a global user variable somewhere, so use that.
e.g.
Code:
& "'" & glblUser & "' as UserID, "_

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top