run SQL statement issue

A

Andy

Hi there,

I use a SQL statement to duplicate the record but I do not know how to
displace the new duplicate record immediately after run the SQL statement, I
can only view the duplicate record when I close the form and then open the
form again. I tried add the line "Me.Bookmark = LastModified" but not success.
Appreciate for your help! Thanks in advance!

Here is the code :
Private Sub Command25_Click()

strSql = "INSERT INTO [REQUEST SHEET DETAILS] ( [RS NO], [ITEM NO], QTY,
[UNIT PRICE] ) " & vbCrLf & _
"SELECT [REQUEST SHEET].[RS NO], [QUOTATION TABLE DETAILS].[ITEM NO],
[QUOTATION TABLE DETAILS].QTY, [QUOTATION TABLE DETAILS].[UNIT PRICE] " &
vbCrLf & _
"FROM [QUOTATION TABLE DETAILS] INNER JOIN [REQUEST SHEET] ON [QUOTATION
TABLE DETAILS].[QUOTATION NO] = [REQUEST SHEET].[QUOT NO] " & vbCrLf & _
"WHERE ((([QUOTATION TABLE DETAILS].[QUOTATION NO])='" & Me.[QUOT NO] & "'));"
DBEngine(0)(0).Execute strSql, dbFailOnError

End Sub
 
A

Andy

Thanks so much, Klatuu.
Requery the subform : Me.SubFormName.Requery

Klatuu said:
After the execute statment, requery the form:

Me.Requery
--
Dave Hargis, Microsoft Access MVP


Andy said:
Hi there,

I use a SQL statement to duplicate the record but I do not know how to
displace the new duplicate record immediately after run the SQL statement, I
can only view the duplicate record when I close the form and then open the
form again. I tried add the line "Me.Bookmark = LastModified" but not success.
Appreciate for your help! Thanks in advance!

Here is the code :
Private Sub Command25_Click()

strSql = "INSERT INTO [REQUEST SHEET DETAILS] ( [RS NO], [ITEM NO], QTY,
[UNIT PRICE] ) " & vbCrLf & _
"SELECT [REQUEST SHEET].[RS NO], [QUOTATION TABLE DETAILS].[ITEM NO],
[QUOTATION TABLE DETAILS].QTY, [QUOTATION TABLE DETAILS].[UNIT PRICE] " &
vbCrLf & _
"FROM [QUOTATION TABLE DETAILS] INNER JOIN [REQUEST SHEET] ON [QUOTATION
TABLE DETAILS].[QUOTATION NO] = [REQUEST SHEET].[QUOT NO] " & vbCrLf & _
"WHERE ((([QUOTATION TABLE DETAILS].[QUOTATION NO])='" & Me.[QUOT NO] & "'));"
DBEngine(0)(0).Execute strSql, dbFailOnError

End Sub
 

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

Top