Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying a record and then finding it again

Status
Not open for further replies.

JodyAmy

Programmer
Feb 12, 2001
21
US
I need to copy a record on a form that is bound to a table. I have a button to copy the record and that works fine. Problem is finding the two records again. I decided to use a filter when I click on the copy record button. This works fine also. But, if I want to make a copy of the record that I just changed, my code used the value of the first record in the field that I am using as my criteria instead of the one being displayed on my screen. Requery and Refresh don't seem to work. I'm missing something simple here. Here is the code. Thanks, Jody

Private Sub cmdCopy_Click()
On Error GoTo Err_cmdCopy_Click

Dim varY As String
Dim varName As String
'Me.NAFTA_FILE_NAME.SetFocus
'Me.Filter = "[NAFTA FILE NAME] = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]"
'Me.FilterOn = False
varY = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCopyPVC"
DoCmd.SetWarnings True
Me.Requery
'DoCmd.FindRecord varY, , , , , acAll, True
'DoCmd.ApplyFilter , "[NAFTA FILE NAME] = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]"
'Me.FilterOn = True

Exit_cmdCopy_Click:
Exit Sub

Err_cmdCopy_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdCopy_Click

End Sub

 
Hi jo,

Search on "bookmark" - may help.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Try editing your code with these changes in blue below:

Private Sub cmdCopy_Click()
On Error GoTo Err_cmdCopy_Click

Dim varY As String
Dim varName As String
Me!NAFTA_FILE_NAME.SetFocus
'Me.Filter = "[NAFTA FILE NAME] = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]"
'Me.FilterOn = False
varY = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCopyPVC"
DoCmd.SetWarnings True
Me.Refresh
DoCmd.FindRecord varY
'DoCmd.ApplyFilter , "[NAFTA FILE NAME] = Forms![F-Entry Form-PVC COO]![NAFTA FILE NAME]"
'Me.FilterOn = True

Exit_cmdCopy_Click:
Exit Sub

Err_cmdCopy_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdCopy_Click

End Sub
------------------------------------------------------------

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top