Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Delta, Br. Columbia
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts

    AllowEdits (Access 2000/XP)

    I have a form that needs to allow or disallow additions, edits and deletions depending upon the response to a msgbox question.

    My problem is that the record only exists on the subform (the main form is information only and may not be changed therefore all controls on it are disabled), and if the user wants to edit the record then a new version of the record must be created. Everything works fine except that the change to AllowEdits does not work. The code I am using on the subform starting control (i.e. the one that gets the focus when the forms are opened) is as follows:

    Private Sub NotApplicable_GotFocus()
    Dim response As Variant

    If MsgBox("Do you wish to update this Datasheet", vbYesNo) = vbYes Then
    response = NewRevision(Me.JobID, Me.SiteID, Me.RevisionDate)
    Me.Requery
    Me.AllowEdits = True
    Me.AllowAdditions = True
    Me.AllowDeletions = True
    Me.Repaint
    Else
    Me.AllowEdits = False
    Me.AllowAdditions = False
    Me.AllowDeletions = False
    End If

    End Sub

    The NewRevision function is as follows:

    Public Function NewRevision(JobID, SiteID, RDate)
    Dim tmpQueryDef As QueryDef

    ' create new Datasheet
    Set tmpQueryDef = CurrentDb.QueryDefs("qryAddNewDS_Revision")
    tmpQueryDef.Parameters("strJobID") = JobID
    tmpQueryDef.Parameters("strSiteID") = SiteID
    tmpQueryDef.Parameters("strDate") = RDate
    tmpQueryDef.Execute

    NewRevision = True

    End Function <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: AllowEdits (Access 2000/XP)

    In itself, code to set AllowEdits should work, but I have no idea what the effect of your NewRevision code is. Could you post a stripped down copy of the database?

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: AllowEdits (Access 2000/XP)

    What is the purpose of this line of code:
    response = NewRevision(Me.JobID, Me.SiteID, Me.RevisionDate)

    And what does NewRevision do? If it is changing the value of a control, then you have already made the form dirty BEFORE telling Access you don't want to allow edits!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Delta, Br. Columbia
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: AllowEdits (Access 2000/XP)

    Sorry guys - I found the problem. Stupidly I had created a query to feed the form that did not allow editing of the underlying data. There was nothing wrong with the form or the code. By the way the NewRevision function executes a query to add a new record to the table. This new record is the new revision of the Job Datasheet so has a new revision date and ID #.

    <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •