Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250

    NewRecord is a property of the form itself and I reference that in the Form_Current event.

  2. #17
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    The error when using my button to swap between data entry = true and data entry = false was just when I tried the code you suggested earlier, which has since been removed due to the errors. It was not what I was trying to fix.

    I need the forms to not add any new records when making changes in "edit mode" (edit mode meaning DataEntry=False). If someone starts making changes while DataEntry=False, the form adds it as a new record instead of just editing the existing record. I want the form to either be:

    DataEntry=True and the user is adding new records to the database

    Or

    DataEntry=False and the user is editing records in the database and cannot add any new records.

    Also, clicking the record navigation at the bottom of the form as you said, does not produce any prompt. On top of that, it only navigates the records tied to the main form, not records in the subforms. To my understanding, it is not related to what I am trying to accomplish.

    Sorry for the confusion


    EDIT:

    Just saw what you said about the NewRecord bit in the CurrentEvent. I was able to recreate the issue with the form adding new records while DataEntry = False with this code in place, so that doesn't fix the problem unfortunately

  3. #18
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    The code would only prevent new records in the main form.

  4. #19
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    This appears to be working properly, thank you for the help, it is very much appreciated.


    In case anyone else is having this problem in the future, heres the code Gicu put in CurrentEvent:

    Code:
    If Me.DataEntry = False Then
        If Me.NewRecord = True Then
            MsgBox "You cannot add a new record in lookup mode!", vbCritical, "New Record Detected"
            Me.Requery
        End If
    End If

  5. #20
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    If you want to implement it for the subforms simply change the Me.NewRecord to Me.Parent.Form.NewRecord and add it to the current event od each subform.
    Cheers,
    Vlad

  6. #21
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Sorry, actually you want to check for
    If Me.Parent.Form.DataEntry=False then
    If Me.NewRecord = True then.....

    You might need to tweak the code for the cases where there are no existing records and the subform goes automatically to a new record. You could add another test like If Me.recordset.recordcount=0 then ...

    But you need to think this through, how would you deal with these cases?

    I also noticed that some of the subforms are not limited to current AssetID (not master/child linking and no criteria in their recordsource), so you might also want to review that.
    Example for code in subform:
    Code:
    
    
    Code:
    Private Sub Form_Current()
    If Me.Parent.Form.DataEntry = False Then
        If Me.NewRecord = True Then
            MsgBox "You cannot add a new record in lookup mode!", vbCritical, "New Record Detected"
            Me.Requery
        End If
    End If
    End Sub



    Cheers,
    Vlad

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-19-2016, 03:56 AM
  2. subforms allowing additions
    By Csalge in forum Forms
    Replies: 5
    Last Post: 04-05-2013, 09:36 PM
  3. Time dependant disable edits
    By ErinMcArthur in forum Security
    Replies: 1
    Last Post: 11-09-2012, 02:42 PM
  4. Allow Additions Msg Box
    By rossi45 in forum Forms
    Replies: 3
    Last Post: 04-23-2012, 02:51 PM
  5. Allow additions on .accdr
    By dougie in forum Forms
    Replies: 0
    Last Post: 02-20-2012, 05:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums