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!

Archive Records In Table

Status
Not open for further replies.

gator9

Technical User
May 17, 2002
162
US
Ok I have a table call "Projects" and I have created a table called "Archived Projects". What I need to do is when I click on a command button I want to see a prompt that ask for and ID. When I type in the ID it will archive and move every record associated with that ID to the Archived Projects table. Can anyone help?

Thanks

Charles
 
Sub YourButton_Click()
Dim IDNo As String
IDNo = InputBox("Enter ID")
If IsNumeric(IDNo) Then
DoCmd.SetWarnings False
'Append the records to archive
DoCmd.RunSQL("Insert Into [Archived Projects] Select * From Projects Where [IDFieldName] = " & IDNo & ";")

'delete records from Projects
DoCmd.RunSQL("Delete * From Projects Where [IDFieldName] = " & IDNo & ";")
DoCmd.SetWarnings True
Else
MsgBox "You have to enter a number"
End If
End Sub

That should do...
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Had to do a little mod to make it one step but it works great!!!!!!

Thanks
Charles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top