Write to table then read data

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
 
J

Jeff Boyce

You've described a "how" ... i.e., how you are trying to accomplish
something.

Now, "what" and "why"? It sounds like you'd like to be able to see the data
that's just been entered. If so, why "clear" the form? Why not just
preserve the form/data on it and have the user click a button to create a
new record (you'd clear the form then).

You can bind a form to a query (and/or the underlying table), so the data
showing would BE the new data -- no need to "copy to table".

More information, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Send data to table 11
Transfer data 14
New ID 1
Capture Date deleted 5
record changed values 1
OpenRecordSet Error 3
User Defining Problem 2
Dialog in MsgBox 4

Top