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

deleting a subform record

Status
Not open for further replies.

GerryGoldberg

Technical User
Apr 12, 2001
55
I want to delete a record on a subform where the user has omitted one or more important fields. I think that I should do this in the "AfterInsert" event, but I'm not sure of the VB code to use.

Thanks
 
Here's a guideline using ADO. You can of course use DAO.

Dim cnADO as ADODB.Connection
Dim rsADO as New ADODB.Recordset

If (Delete conditions are fulfilled) then
'Connect to the DB
Set cnADO = CurrentProject.Connection
'Open myTbl - record deleted from this tbl
rsADO.Open "myTbl", cnADO, adOpenKeyset, _ adLockOptimistic, adCmdTable
'Find the matching record
rsADO.Find "Match condition", , _ adSearchForward, acFirst
'Check match was found
if not rsADO.EOF then
rsADO.Delete
end if
'Clean up
rsADO.Close
set rsADO = Nothing
cnADO.Close
set cnADO = Nothing
End If
Hope this helps Raymondo
raymondo@rossar.net
 
Woops! I misread your question. I thought tha data had already left the form. To just clear the form it's much easier.

Form_subformName.undo

That should take you back to the starting blocks.
Sorry for the 1st rather over enthousiastic reponse!! Raymondo
raymondo@rossar.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top