G
Guest
On a form I have a command button with the following code.
When clicked it copies the current forms data to a table and opens a form
which has that copied data.
First time thru it works fine, but when the record is edited and this button
is clicked the data is not updated.
I realise every time the buoon is clicked it writes new data to the table
but how can I make it pull the most current data from the table?
I don't want to over write the data in the table.. Do I need to give more
information??
Suggestions??
stDocName = "frmLetterVals"
lICCNNO = Me!ICNNo
lID = Nz(DMax("ID", "tblLetterVals"), 0) + 1
lCriteria = "INSERT INTO tblLetterVals (ID, ICNNo, ProvNo, ReceiptDate,
SummaryofComplaint, CurrentDate)"
lCriteria = lCriteria & "SELECT " & lID & " AS ID, tblQualityData.ICNNo,
tblQualityData.ProvNo, tblQualityData.CSReceiptDate, "
lCriteria = lCriteria & " tblQualityData.SummaryofComplaint,"
lCriteria = lCriteria & "#" & Format$(Now, "mm\/dd\/yyyy") & "# AS
CurrentDate "
lCriteria = lCriteria & "FROM tblQualityData "
lCriteria = lCriteria & "WHERE (((tblQualityData.ICNNo)=" & """" & lICCNNO &
"""" & "));"
CurrentDb.Execute lCriteria, DAO.dbFailOnError
'DoCmd.RunSQL lCriteria
'Debug.Print lCriteria
stLinkCriteria = "[ICNNo]=" & "'" & Me![ICNNo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
When clicked it copies the current forms data to a table and opens a form
which has that copied data.
First time thru it works fine, but when the record is edited and this button
is clicked the data is not updated.
I realise every time the buoon is clicked it writes new data to the table
but how can I make it pull the most current data from the table?
I don't want to over write the data in the table.. Do I need to give more
information??
Suggestions??
stDocName = "frmLetterVals"
lICCNNO = Me!ICNNo
lID = Nz(DMax("ID", "tblLetterVals"), 0) + 1
lCriteria = "INSERT INTO tblLetterVals (ID, ICNNo, ProvNo, ReceiptDate,
SummaryofComplaint, CurrentDate)"
lCriteria = lCriteria & "SELECT " & lID & " AS ID, tblQualityData.ICNNo,
tblQualityData.ProvNo, tblQualityData.CSReceiptDate, "
lCriteria = lCriteria & " tblQualityData.SummaryofComplaint,"
lCriteria = lCriteria & "#" & Format$(Now, "mm\/dd\/yyyy") & "# AS
CurrentDate "
lCriteria = lCriteria & "FROM tblQualityData "
lCriteria = lCriteria & "WHERE (((tblQualityData.ICNNo)=" & """" & lICCNNO &
"""" & "));"
CurrentDb.Execute lCriteria, DAO.dbFailOnError
'DoCmd.RunSQL lCriteria
'Debug.Print lCriteria
stLinkCriteria = "[ICNNo]=" & "'" & Me![ICNNo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria