|
|
I want a form to be kept sort of readonly until a newrecord button is pressed:
In Form_AfterUpdate() I use:
If Me.NewRecord = True Then Me.RecordsetType = 0 'Dynaset Else Me.RecordsetType = 2 'Snapshot End If
Then, when the button is pressed I use:
Me.RecordsetType = 0 'Dynaset DoCmd.GoToRecord , , acNewRec
Then I get the message that "you can't go to the specified record"
Can I have some help, please. I also tried Form_BeforeUpdate() and Form_Current(), I can't get it running.
Can I have some help, pelase?
Thanks H. Martins
|
|
"H. Martins" <HJRMartins[ at ]gmail.com> wrote in message news:c50ad520-41b2-440c-a6f6-aeef464a415c[ at ]w35g2000yqm.googlegroups.com...
[Quoted Text] >I want a form to be kept sort of readonly until a newrecord button is > pressed: > > In Form_AfterUpdate() I use: > > If Me.NewRecord = True Then > Me.RecordsetType = 0 'Dynaset > Else > Me.RecordsetType = 2 'Snapshot > End If > > Then, when the button is pressed I use: > > Me.RecordsetType = 0 'Dynaset > DoCmd.GoToRecord , , acNewRec > > Then I get the message that "you can't go to the specified record" > > Can I have some help, please. I also tried Form_BeforeUpdate() and > Form_Current(), I can't get it running. > > Can I have some help, pelase?
I don't know exactly what's going on, as I've never tried to manipulate the form's RecordsetType property on the fly. Does it work at all?
I don't think I'd do it this way, though. Instead, I would manipulate the form's AllowAdditions property. Something like this:
'----- start of code ----- Private Sub cmdAddRecord_Click()
Me.AllowAdditions = True RunCommand acCmdRecordsGoToNew
End Sub
Private Sub cmdCancelAdd_Click()
Me.Undo Me.AllowAdditions = False
End Sub
Private Sub Form_AfterInsert()
Me.AllowAdditions = False
End Sub
Private Sub Form_Current()
If Not Me.NewRecord Then Me.AllowAdditions = False End If
End Sub '----- end of code -----
The AllowEdits and AllowDeletions properties would be set to No in the form design, and would stay that way unless I wanted to control those operations also via a command button.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
Thank you Dirk,
As much as I can see, my problem is not about allowing or not to add new or delete records.
My problem goes on how to make a form read-only and how to make it read/wright so that a new record can be added (or deleted).
Me.AllowAdditions just disable the creation of new records, do not disabling editing already existing records.
Thanks H. Martins
|
|
There's also Me.AllowEdits and Me.AllowDeletions, in addition to Me.AllowAdditions.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
"Range-o-Dente da Silva" <range.o.dente[ at ]gmail.com> wrote in message news:4cc99b9e-838a-4824-b1d9-5e05bf5a98ac[ at ]v42g2000yqv.googlegroups.com...
[Quoted Text] > Thank you Dirk, > > As much as I can see, my problem is not about allowing or not to add > new or delete records. > > My problem goes on how to make a form read-only and how to make it > read/wright so that a new record can be added (or deleted). > > Me.AllowAdditions just disable the creation of new records, do not > disabling editing already existing records. > > Thanks > H. Martins >
|
|
You could use:
Private Sub Form_Current
me.AllowEdits = me.NewRecord
End Sub
Private sub cmd_Edit_Click
me.AllowEdits = True
End Sub
-- HTH Dale
email address is invalid Please reply to newsgroup only.
"H. Martins" wrote:
[Quoted Text] > I want a form to be kept sort of readonly until a newrecord button is > pressed: > > In Form_AfterUpdate() I use: > > If Me.NewRecord = True Then > Me.RecordsetType = 0 'Dynaset > Else > Me.RecordsetType = 2 'Snapshot > End If > > Then, when the button is pressed I use: > > Me.RecordsetType = 0 'Dynaset > DoCmd.GoToRecord , , acNewRec > > Then I get the message that "you can't go to the specified record" > > Can I have some help, please. I also tried Form_BeforeUpdate() and > Form_Current(), I can't get it running. > > Can I have some help, pelase? > > Thanks > H. Martins > >
|
|
"Range-o-Dente da Silva" <range.o.dente[ at ]gmail.com> wrote in message news:4cc99b9e-838a-4824-b1d9-5e05bf5a98ac[ at ]v42g2000yqv.googlegroups.com...
[Quoted Text] > Thank you Dirk, > > As much as I can see, my problem is not about allowing or not to add > new or delete records. > > My problem goes on how to make a form read-only and how to make it > read/wright so that a new record can be added (or deleted). > > Me.AllowAdditions just disable the creation of new records, do not > disabling editing already existing records.
As I mentioned, you can also manipulate the AllowEdits and AllowDeletions properties in a very similar fashion. It's up to you to decide what you want to restrict or allow.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
Hi Dirk,
Me.AllowEdits is much better than Me.RecordsetType
AllowEdits and AllowDeletions is also very handy.
It worked perfectly.
Thanks HM.
|
|
|