Re: Open form, Edit button, etc

From: Aniko (anonymous_at_discussions.microsoft.com)
Date: 07/23/04


Date: Thu, 22 Jul 2004 22:47:18 -0700

Hi Tina,
I rolled back to an earlier version of the database and
realised that the Edit button only activates the main form
fields, but not the subforms'. In other words, when opening
the main form the record is locked for editing but only the
main form part. The subform part can still be edited.
Do I need to add your codes to all the subforms as well?
And how am I to change the Edit button onCLick event to
unlock the subforms as well as the main form?

Thanks for your time,
Aniko

>-----Original Message-----
>well, the code i gave you was pretty limited really,
shouldn't have had such
>a massive effect. if you want me to take a look at your db
(the "after code
>was added" copy), post back with your email address
(beware the spammers)
>and i'll email you.
>
>
><anonymous@discussions.microsoft.com> wrote in message
>news:02b701c46df1$d86d6390$a401280a@phx.gbl...
>> Hi,
>> I went back to a copy of the database before the codes were
>> added and yes I am able to edit the sub-form of existing
>> records.
>> However, I have an error message when adding a new record,
>> which was rectified by Dirk, that I should have a default
>> value for the option group 1+ the number of tabs
>> corresponding to the option group.
>>
>> Now I am unable to edit existing record's sub-forms after
>> clicking the Edit button, and unable to enter anything to
>> the sub-form when adding new records, as the sub-form is no
>> longer visible in a new record.
>>
>> Thanks for your help,
>> Aniko
>>
>> >-----Original Message-----
>> >are you able to add subform records when adding a *new*
>> mainform record?
>> >and are you able to edit subform records after up clicking
>> the Edit button?
>> >were you able to edit subform records in new and/or
>> existing mainform
>> >records before adding the code i posted?
>> >
>> >
>> ><anonymous@discussions.microsoft.com> wrote in message
>> >news:2e31b01c46c7c$4a52a050$a601280a@phx.gbl...
>> >> Hi Tina,
>> >>
>> >> I have implemented all your suggestions, but I just
>> >> realised that some part of the form is not editable.
>> >>
>> >> I have a main form and on it option buttons to select the
>> >> corresponding tab controls. The tab controls hold sub
>> >> forms. And none of them are able to be amended.
>> >>
>> >> Any help would be much appreciated.
>> >>
>> >> Kind regards,
>> >> Aniko
>> >>
>> >> >-----Original Message-----
>> >> >you can add the following code to the form's Current
>> event, as
>> >> >
>> >> >Private Sub Form_Current()
>> >> >
>> >> > Me.AllowEdits = Me.NewRecord
>> >> >
>> >> >End Sub
>> >> >
>> >> >each time you move from one record to another, the
record
>> >> will be locked -
>> >> >unless it is a new record. so the user can add a new
>> >> record without
>> >> >interference, but is stopped from editing an existing
>> >> record. Note: the
>> >> >user can also delete an existing record entirely,
without
>> >> interference.
>> >> >
>> >> >add a command button for editing and add the following
>> >> code. i called the
>> >> >command button cmdEdit, and put the code on the Click
>> >> event, as
>> >> >
>> >> >Private Sub cmdEdit_Click()
>> >> >
>> >> > Me.AllowEdits = True
>> >> >
>> >> >End Sub
>> >> >
>> >> >to stop automatic saving of an edited record, add the
>> >> following code to the
>> >> >form's BeforeUpdate event, as
>> >> >
>> >> >Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >> >
>> >> > If Me.Dirty And Not Me.NewRecord Then
>> >> > If MsgBox("Do you want to save your changes?", _
>> >> > vbOKCancel + vbDefaultButton2) =
vbCancel Then
>> >> > Cancel = True
>> >> > Me.Undo
>> >> > MsgBox "Changes were not saved."
>> >> > End If
>> >> > End If
>> >> >
>> >> >End Sub
>> >> >
>> >> >if the record is a new record, it will save
automatically.
>> >> if an existing
>> >> >record has been changed, the "Do you want to save?"
>> >> message box pops up. if
>> >> >the user clicks the OK button (default button is set to
>> >> Cancel), then the
>> >> >record is saved and nothing else happens. if the user
>> >> clicks the Cancel
>> >> >button, the changes are "undone" and the "changes not
>> >> saved" message box
>> >> >pops up.
>> >> >if the user changes a record and then closes the form
>> >> before those changes
>> >> >have been saved or discarded, and chooses to Undo the
>> >> changes, an error will
>> >> >be generated. to handle the error, add the following
code
>> >> to the form's
>> >> >OnError event, as
>> >> >
>> >> >Private Sub Form_Error(DataErr As Integer, Response As
>> >> Integer)
>> >> >
>> >> > If DataErr = 2169 Then
>> >> > Response = acDataErrContinue
>> >> > End If
>> >> >
>> >> >End Sub
>> >> >
>> >> >suggest you read up on the various form events and
>> >> properties that are used
>> >> >in the above code, so you'll understand how they work.
>> >> >
>> >> >hth
>> >> >
>> >> >
>> >> >"Aniko" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >> >news:2e7bd01c46af1$f1393fa0$a301280a@phx.gbl...
>> >> >> Hi,
>> >> >> When I open a form I would like the record to be
>> locked, so
>> >> >> users cannot accidentally amend any fields of the
>> record. I
>> >> >> would like to add a button called Edit, which
would make
>> >> >> the record editable and the Save button, which
could be
>> >> >> used to save the record only if the user is happy
>> with it.
>> >> >> (I did find the Save button, but not sure how to
stop the
>> >> >> Access saving automatically.)
>> >> >> Could someone please help me to solve this problem?
>> >> >>
>> >> >> Thank you,
>> >> >> Aniko
>> >> >>
>> >> >
>> >> >
>> >> >.
>> >> >
>> >
>> >
>> >.
>> >
>
>
>.
>