Anj
Posts: 13
|
Posted: 07/19/2008, 8:54 PM |
|
Hi,
I am new to the coding and would greatly appreciate some assistance. Have spent 2 days on it and going insane.
Not sure what is wrong with the code below but its not working, probably a syntax error.
I have placed it on an after execute insert event.
Dim SQL
Dim Connection
Dim ErrorMessage
Dim CurrentLogHeaderID
Dim MaxHeaderSQL
Set Connection = New clsDBConnection1
Connection.Open
MaxHeaderSQL = "SELECT Max([H-LogHeader].LogHeaderID)" &_
"FROM [H-LogHeader];"
Set CurrentLogHeaderID = Connection.Execute(MaxHeaderSQL)
SQL = "INSERT INTO [H-LogDetail] (HeaderID, [No], Description, AASID ) "&_
" SELECT [H-LogHeader].LogHeaderID, [H-LogbookChecklist].[No], [H-LogbookChecklist].Description, [H-LogHeader].AssetID "&_
" FROM [H-LogHeader] INNER JOIN [H-LogbookChecklist] ON [H-LogHeader].AssetID = [H-LogbookChecklist].AssetID;" &_
"WHERE [H-LogbookChecklist].AssetID = CCDLookup ( 'AssetID', '[H-LogHeader]', 'LogHeaderID =' & CurrentLogHeaderID, DBConnection1)"
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
|
|
|
|