append query question

S

Steve

I am trying to facilitate user data entry. I am contructing a database that
tracks procedural data. One data element that is tracked is the list of
equipment used in the procedure. For many of the basic procedures the same
equipment is used. Rather than having the data entry personel have to
individually select each peice of equipment for every study I am attempting
to create a "quick pick" button that populates the equipment list for that
procedure. I have created a button with the following code. I store the
"default" equipment list in a table called tblQPEquipment. The destination
table is tblEquipment. This works fine for the equipment but I also need to
get the appropriate study ID (intEPSID) added to each new record in
tblEquipment. This, of course, can't be stored in tblQPEquipment becuase it
will change with each new study. It is available on an open subform in the
control: Forms!frmMaster!fsubOpenEPS!txtEPSID. My question is how do I modify
this insert query so that intEPSID can be derived from
Forms!frmMaster!fsubOpenEPS!txtEPSID and the rest of the data taken from
tblQPEquipment? Thanks for any help.

Private Sub cmdQPEquipment_Click()
Dim strSQL As String

strSQL = "INSERT INTO tblEquipment (intEPSID, intEquipmentLkpID,
chrAccessPoint, chrEntrySite, chrTipLocation )" & _
"SELECT tblQPEquipment.intEPSID, tblQPEquipment.intEquipmentLkpID,
tblQPEquipment.chrAccessPoint, tblQPEquipment.chrEntrySite,
tblQPEquipment.chrTipLocation " & _
"FROM tblQPEquipment;"

DoCmd.RunSQL strSQL
Me.lbxEquipment.Requery

End Sub
 
C

Clifford Bass

Hi Steve,

Try:

strSQL = "INSERT INTO tblEquipment (intEPSID, intEquipmentLkpID,
chrAccessPoint, chrEntrySite, chrTipLocation) " & _
"SELECT " & [Forms]![frmMaster]![fsubOpenEPS]![txtEPSID] & ",
tblQPEquipment.intEquipmentLkpID,
tblQPEquipment.chrAccessPoint, tblQPEquipment.chrEntrySite,
tblQPEquipment.chrTipLocation " & _
"FROM tblQPEquipment"

Clifford Bass
 
S

Steve

Thanks! That works great.
--
Steve


Clifford Bass said:
Hi Steve,

Try:

strSQL = "INSERT INTO tblEquipment (intEPSID, intEquipmentLkpID,
chrAccessPoint, chrEntrySite, chrTipLocation) " & _
"SELECT " & [Forms]![frmMaster]![fsubOpenEPS]![txtEPSID] & ",
tblQPEquipment.intEquipmentLkpID,
tblQPEquipment.chrAccessPoint, tblQPEquipment.chrEntrySite,
tblQPEquipment.chrTipLocation " & _
"FROM tblQPEquipment"

Clifford Bass

Steve said:
I am trying to facilitate user data entry. I am contructing a database that
tracks procedural data. One data element that is tracked is the list of
equipment used in the procedure. For many of the basic procedures the same
equipment is used. Rather than having the data entry personel have to
individually select each peice of equipment for every study I am attempting
to create a "quick pick" button that populates the equipment list for that
procedure. I have created a button with the following code. I store the
"default" equipment list in a table called tblQPEquipment. The destination
table is tblEquipment. This works fine for the equipment but I also need to
get the appropriate study ID (intEPSID) added to each new record in
tblEquipment. This, of course, can't be stored in tblQPEquipment becuase it
will change with each new study. It is available on an open subform in the
control: Forms!frmMaster!fsubOpenEPS!txtEPSID. My question is how do I modify
this insert query so that intEPSID can be derived from
Forms!frmMaster!fsubOpenEPS!txtEPSID and the rest of the data taken from
tblQPEquipment? Thanks for any help.

Private Sub cmdQPEquipment_Click()
Dim strSQL As String

strSQL = "INSERT INTO tblEquipment (intEPSID, intEquipmentLkpID,
chrAccessPoint, chrEntrySite, chrTipLocation )" & _
"SELECT tblQPEquipment.intEPSID, tblQPEquipment.intEquipmentLkpID,
tblQPEquipment.chrAccessPoint, tblQPEquipment.chrEntrySite,
tblQPEquipment.chrTipLocation " & _
"FROM tblQPEquipment;"

DoCmd.RunSQL strSQL
Me.lbxEquipment.Requery

End Sub
 
Top