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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I delete a record when the form is in pop up?

Status
Not open for further replies.

pmo

Technical User
Jan 15, 2001
76
AU
I have a main form that opens another form over the top. I can create a button using a wizard that deletes the displayed record which works fine. The problem is that when I turn this second form into a pop up form to display the records my delete button doesn't work. I assume that I could write a module to delete the record but I don't know how to do this. Is anyone able to structure such so that I can copy it into a module and run it from there.

Thanks in anticipation for your help
Wayne
 
Hi Wayne!

The following code assumes that your pop-up form, or the calling form, has a text box containing an ID that uniquely identifies each record in the data:

Private Sub YourButton_Click()

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("YourTable", dbOpenDynaset)
rs.FindFirst "YourID = '" & Me!YourTextBox & "'" OR USE
rs.FindFirst "YourID = '" & Forms!YourForm!YourTextBox & "'"

If rs.NoMatch = True Then
some error message here
Else
rs.Delete
End If

Set rs = Nothing

End Sub

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top