Delete record if no entry

aron.ridgway

Registered User.
Local time
Today, 23:35
Joined
Apr 1, 2014
Messages
148
I have a form that opens up and fills in all of the Orders Table when it opens.
I then have a subform that is used to fill in the order details.
Currently if they open the form and then close it, it creates a record in the order table. I want to be able to delete this record if no information has been filled into the subform?

how do i go about doing this? any help would be great!

thanks
 
You are hitting a logical absurdity here, your premise "add records on form open", then you conclude "if no details are entered in subform". How is this possible? To add record means to put in some information. A parent record is created which means a child record (at least in most cased) should exist.

Explain your set up a little bit.
 
I understand it sounds strange, But when the form is opened all of the Order PK, FK are automatically populated from the previous form. So the order table has all of its relevant information.

The subform that controls the orderDetails is blank when the master form opens, as soon as you type in the subform then a record is created into the orderdetails table.

But if for some reason you open the master Orderform, but do not select the subform and exit the main form. Then im receiving an entry into the Order table but no records into the Orderdetail.

The case of this happening are slim but if they click to make an order by mistake and immedietly exit then i want to avoid the entry.
 
Can't you check on the master form's on close/unload event, if there is a relate record in the subform or better in the table the subform is bound to?
 
Thanks that sounds like what i need, what kind of code do i need to do this??
 
Code:
Private Sub Form_Close()
  
  If Me.[MySubformName].Form.RecordsetClone.RecordCount=0 Then
    'Do some stuff here.   
  End If
End Sub
 
I have used an unbound form with a "save" command button. The "save" button checks to verify the data in each control. If the data is confirmed valid, a DAO records set is temporarily created to create/save the new record.

PS: There is also a cancel button to allow the form to be closed without action.
 

Users who are viewing this thread

Back
Top Bottom