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!

Set subform to allow edits

Status
Not open for further replies.

Wrathchild

Technical User
Aug 24, 2001
303
US
Hi, I have a subform I would like to allowedits, but not on the main form. The setting on the main form overrides the subform and doesn't allow me to edit (add records). Anyway around this? Also, is there a way to stop Access from saving a record when I get out of the new record? I would like to use a 'save record' button instead.

thanks!
 
For the first question:

In the On Open event of the main form write

Me!SubFormControlName.Form.AllowEdits = True

For the second question:

I don't think you can avoid saving record after moving to another. I suggest you create a temporary table in which user can insert data and when user cliks Save button, move the data to desired table.

Hope it helps
Mangro
 
Yes, there is a way to prevent, or atleast confirm saving changes.

I do this for a database I'm developing.

For a cancel button, I use:

Private Sub cancel_Click()
Me.Undo
DoCmd.GoToRecord , , acLast
End Sub

For the form's before update event, you could use:

Private Sub Form_BeforeUpdate(cancel As Integer)
If theForm.Dirty Then
If MsgBox("Do you want to save?", vbYesNo + _
vbQuestion, "Save Record") = vbNo Then
cancel = True
theForm.Undo
End If
End If
End Sub

I'm still working on the OK button. I thought

Private Sub ok_Click()
DoCmd.Save
End Sub

would do, but I don't think that's right. I'll let you know.

Manngo


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top