Clear subform on acNewRecord in Main

thart21

Registered User.
Local time
Today, 14:44
Joined
Jun 18, 2002
Messages
236
I cannot figure out how to do this one.

I have a main form with a subform linked by cableid. I put a command button on my main form DoCmd.GoToRecord, , acNewRecord which works fine to clear the fields in my main form.

I don't want to just add a new record to my subform, I want to completely clear out all of the records in it.

Everything I have tried just points me to a new record in the subform, leaving the previous data.

Any ideas? Thank you!

Toni
 
If you have your subform linked to the main form by cableid when you create a brand new record the subform should show no records because there won’t (or shouldn’t) be any related records for your new cableid. Are you sure you have your form and subform linked correctly. What is the link you are using now?
 
I thought it should work that way. I have my subform linked by cableid which is the first column of my combo box "partnumber" in my main form. My bound column is "1" and I have cableid not visible in the combo.

Thanks for the help
 
Command Button

Hello. Not sure if this is what you mean, used this on an old DB of mine. Add it to the On Click event of your command button (Customize to suit if it is what you were after that is!!).

Code:
Private Sub cmdClearForm_Click()
On Error GoTo Err_cmdClearForm_Click

Dim Msg, Style, Title, Response

Msg = "Do you want to re-set the Form?"
Style = vbYesNo
Title = "Reset Form"
Response = MsgBox(Msg, Style, Title)
Select Case Response
Case vbYes
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Case vbNo
Screen.PreviousControl.SetFocus
End Select
     
Exit_cmdClearForm_Click:
    Exit Sub

Err_cmdClearForm_Click:
    MsgBox Err.Description
    Resume Exit_cmdClearForm_Click
End Sub
Phil.
 

Users who are viewing this thread

Back
Top Bottom