A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL append query using A2K



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2005, 08:59 PM
Ted
external usenet poster
 
Posts: n/a
Default SQL append query using A2K

the following is my append query at this writing

INSERT INTO [Adverse Events (child)]
SELECT T1.[Patient Number] AS [Patient Number], T1.Cycle+1 AS Cycle, T1.[AE
Description] AS [AE Description], T1.Subtype AS Subtype, T1.Onset AS Onset,
T1.Resolved AS Resolved, T1.[Continuing as of] AS [Continuing as of],
T1.Grade AS Grade, T1.Attribution AS Attribution, T1.Serious AS Serious,
T1.Action AS [Action], T1.Outcome AS Outcome, T1.DLT AS DLT, T1.[AER Filed]
AS [AER Filed], "No" AS ContinuingEndCycle, T1.Updates AS Updates
FROM [Adverse Events (child)] AS T1 LEFT JOIN [Adverse Events (child)] AS T2
ON (T1.Onset=T2.Onset) AND (T1.Subtype=T2.Subtype) AND (T1.[AE
Description]=T2.[AE Description]) AND (T1.[Patient Number]=T2.[Patient
Number]) AND (T1.Cycle+1=T2.Cycle)
WHERE (((T1.[Patient Number]=[Forms]![Treatment and Toxicity].[Patient
Number]) And ((T1.ContinuingEndCycle)="Yes") And ((T2.[Patient Number]) Is
Null)));


it replaces some VBA code following this line


Private Sub Duplicate_Click()
Dim Response As Integer
' pending pending
Response = MsgBox("Before proceding to duplicate this record, verify that
the top part of this form " & Chr(13) & _
"for this patient's next cycle (i.e., MR and Cycle) were already entered.
If not, press 'Cancel', otherwise press 'OK'.", vbOKCancel + vbCritical +
vbDefaultButton2, "Critical !")
If Response = 1 Then
With Me.RecordsetClone
.AddNew
![Patient Number] = Me.Patient_Number
' ignore ![Cycle] = Me.Cycle + 1
![Cycle] = Forms![Treatment and Toxicity].[Current Cycle
Number] + 1
![AE Description] = Me.AE_Description
![Subtype] = Me.Subtype
![Onset] = Me.Onset
![Grade] = Me.Grade
![Serious] = Me.Serious
![Attribution] = Me.Attribution
![Action] = Me.Action
![Outcome] = Me.Outcome
![DLT] = Me.DLT
![AER Filed] = Me.AER_Filed
![ContinuingEndCycle] = "No"
' the following is intended to add a comment in the Updates
field
![Updates] = "On " & Now() & " , " & LAS_GetUserName() & "
duplicated this patient's Cycle #" & Forms![Treatment and Toxicity].[Current
Cycle Number] & " record."
.Update
Me.Bookmark = .LastModified
End With
Else

now here's the QUESTION: how can i stuff the info from this line in the
immediately above VBA into my SQL query?


![Updates] = "On " & Now() & " , " & LAS_GetUserName() & " duplicated this
patient's Cycle #" & Forms![Treatment and Toxicity].[Current Cycle Number] &
" record."


everything to the right of the "=" sign would ideally appear in the Updates
field whenever a new record were appended using the SQL query at top.

hope this makes sense to some guru out there?



  #2  
Old February 26th, 2005, 07:34 AM
Naresh Nichani MVP
external usenet poster
 
Posts: n/a
Default

Hi:

One idea is to make this a parameter query and invoke from code and pass
parameters via code.
Some articles on this --

http://support.microsoft.com/kb/q142938/

http://www.tek-tips.com/faqs.cfm?fid=2205

Regards,

Naresh Nichani
Microsoft Access MVP




"Ted" wrote in message
...
the following is my append query at this writing

INSERT INTO [Adverse Events (child)]
SELECT T1.[Patient Number] AS [Patient Number], T1.Cycle+1 AS Cycle,

T1.[AE
Description] AS [AE Description], T1.Subtype AS Subtype, T1.Onset AS

Onset,
T1.Resolved AS Resolved, T1.[Continuing as of] AS [Continuing as of],
T1.Grade AS Grade, T1.Attribution AS Attribution, T1.Serious AS Serious,
T1.Action AS [Action], T1.Outcome AS Outcome, T1.DLT AS DLT, T1.[AER

Filed]
AS [AER Filed], "No" AS ContinuingEndCycle, T1.Updates AS Updates
FROM [Adverse Events (child)] AS T1 LEFT JOIN [Adverse Events (child)] AS

T2
ON (T1.Onset=T2.Onset) AND (T1.Subtype=T2.Subtype) AND (T1.[AE
Description]=T2.[AE Description]) AND (T1.[Patient Number]=T2.[Patient
Number]) AND (T1.Cycle+1=T2.Cycle)
WHERE (((T1.[Patient Number]=[Forms]![Treatment and Toxicity].[Patient
Number]) And ((T1.ContinuingEndCycle)="Yes") And ((T2.[Patient Number]) Is
Null)));


it replaces some VBA code following this line


Private Sub Duplicate_Click()
Dim Response As Integer
' pending pending
Response = MsgBox("Before proceding to duplicate this record, verify that
the top part of this form " & Chr(13) & _
"for this patient's next cycle (i.e., MR and Cycle) were already entered.
If not, press 'Cancel', otherwise press 'OK'.", vbOKCancel + vbCritical +
vbDefaultButton2, "Critical !")
If Response = 1 Then
With Me.RecordsetClone
.AddNew
![Patient Number] = Me.Patient_Number
' ignore ![Cycle] = Me.Cycle + 1
![Cycle] = Forms![Treatment and Toxicity].[Current Cycle
Number] + 1
![AE Description] = Me.AE_Description
![Subtype] = Me.Subtype
![Onset] = Me.Onset
![Grade] = Me.Grade
![Serious] = Me.Serious
![Attribution] = Me.Attribution
![Action] = Me.Action
![Outcome] = Me.Outcome
![DLT] = Me.DLT
![AER Filed] = Me.AER_Filed
![ContinuingEndCycle] = "No"
' the following is intended to add a comment in the

Updates
field
![Updates] = "On " & Now() & " , " & LAS_GetUserName() & "
duplicated this patient's Cycle #" & Forms![Treatment and

Toxicity].[Current
Cycle Number] & " record."
.Update
Me.Bookmark = .LastModified
End With
Else

now here's the QUESTION: how can i stuff the info from this line in the
immediately above VBA into my SQL query?


![Updates] = "On " & Now() & " , " & LAS_GetUserName() & " duplicated this
patient's Cycle #" & Forms![Treatment and Toxicity].[Current Cycle Number]

&
" record."


everything to the right of the "=" sign would ideally appear in the

Updates
field whenever a new record were appended using the SQL query at top.

hope this makes sense to some guru out there?





  #3  
Old February 26th, 2005, 01:53 PM
Ted
external usenet poster
 
Posts: n/a
Default

hi,

what i did was rewrite

"On " & Now() & " , " & LAS_GetUserName() & " duplicated this
patient's Cycle #" & Forms![Treatment and Toxicity].[Current Cycle Number]

into

"On " & Now() & " , " & LAS_GetUserName() & " duplicated this
patient's Cycle #" & T1.Cycle

which was used to replace "T1.Updates" in my SQL code.

based on some limited testing of mine i've done, that did the trick.

thanks for the bandwidth,

-ted






"Naresh Nichani MVP" wrote:

Hi:

One idea is to make this a parameter query and invoke from code and pass
parameters via code.
Some articles on this --

http://support.microsoft.com/kb/q142938/

http://www.tek-tips.com/faqs.cfm?fid=2205

Regards,

Naresh Nichani
Microsoft Access MVP




"Ted" wrote in message
...
the following is my append query at this writing

INSERT INTO [Adverse Events (child)]
SELECT T1.[Patient Number] AS [Patient Number], T1.Cycle+1 AS Cycle,

T1.[AE
Description] AS [AE Description], T1.Subtype AS Subtype, T1.Onset AS

Onset,
T1.Resolved AS Resolved, T1.[Continuing as of] AS [Continuing as of],
T1.Grade AS Grade, T1.Attribution AS Attribution, T1.Serious AS Serious,
T1.Action AS [Action], T1.Outcome AS Outcome, T1.DLT AS DLT, T1.[AER

Filed]
AS [AER Filed], "No" AS ContinuingEndCycle, T1.Updates AS Updates
FROM [Adverse Events (child)] AS T1 LEFT JOIN [Adverse Events (child)] AS

T2
ON (T1.Onset=T2.Onset) AND (T1.Subtype=T2.Subtype) AND (T1.[AE
Description]=T2.[AE Description]) AND (T1.[Patient Number]=T2.[Patient
Number]) AND (T1.Cycle+1=T2.Cycle)
WHERE (((T1.[Patient Number]=[Forms]![Treatment and Toxicity].[Patient
Number]) And ((T1.ContinuingEndCycle)="Yes") And ((T2.[Patient Number]) Is
Null)));


it replaces some VBA code following this line


Private Sub Duplicate_Click()
Dim Response As Integer
' pending pending
Response = MsgBox("Before proceding to duplicate this record, verify that
the top part of this form " & Chr(13) & _
"for this patient's next cycle (i.e., MR and Cycle) were already entered.
If not, press 'Cancel', otherwise press 'OK'.", vbOKCancel + vbCritical +
vbDefaultButton2, "Critical !")
If Response = 1 Then
With Me.RecordsetClone
.AddNew
![Patient Number] = Me.Patient_Number
' ignore ![Cycle] = Me.Cycle + 1
![Cycle] = Forms![Treatment and Toxicity].[Current Cycle
Number] + 1
![AE Description] = Me.AE_Description
![Subtype] = Me.Subtype
![Onset] = Me.Onset
![Grade] = Me.Grade
![Serious] = Me.Serious
![Attribution] = Me.Attribution
![Action] = Me.Action
![Outcome] = Me.Outcome
![DLT] = Me.DLT
![AER Filed] = Me.AER_Filed
![ContinuingEndCycle] = "No"
' the following is intended to add a comment in the

Updates
field
![Updates] = "On " & Now() & " , " & LAS_GetUserName() & "
duplicated this patient's Cycle #" & Forms![Treatment and

Toxicity].[Current
Cycle Number] & " record."
.Update
Me.Bookmark = .LastModified
End With
Else

now here's the QUESTION: how can i stuff the info from this line in the
immediately above VBA into my SQL query?


![Updates] = "On " & Now() & " , " & LAS_GetUserName() & " duplicated this
patient's Cycle #" & Forms![Treatment and Toxicity].[Current Cycle Number]

&
" record."


everything to the right of the "=" sign would ideally appear in the

Updates
field whenever a new record were appended using the SQL query at top.

hope this makes sense to some guru out there?






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested in-line Query laura Running & Setting Up Queries 0 February 11th, 2005 12:17 AM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM
Inconsistent square bracket in Query SQL Christine Running & Setting Up Queries 8 October 7th, 2004 03:49 AM
EXISTS reserved word in FROM clause Stephanie Doherty Running & Setting Up Queries 6 July 21st, 2004 01:15 AM
Hidden files in Ms-Query cause ODBC connect errors or Query is wac needyourhelp General Discussion 4 July 12th, 2004 09:38 PM


All times are GMT +1. The time now is 08:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.