Results 1 to 9 of 9
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Resetting form to original status on record change

    How do you reset the form when you go to a new record or just change a record?

    I have this in VBA:

    Private Sub Form_Load()
    Me.O6Vote.Enabled = False
    Me.GOVote.Enabled = False
    Me.FinalVote.Enabled = False

    Private Sub AOVote_BeforeUpdate(Cancel As Integer)


    Me.O6Vote.Enabled = Not IsNull(AOVote) And Me.Level <> "Level 1"
    Me.O6Vote.Enabled = Me.Level <> "Level 1" Or Me.Level = "Software" And Me.[Soft Level] <> "Level 1"
    Me.FinalVote.Enabled = Not IsNull(AOVote) And Me.Level = "Level 1" Or Me.Level = "Software" And Me.[Soft Level] = "Level 1"
    End Sub

    Private Sub O6Vote_BeforeUpdate(Cancel As Integer)
    Me.GOVote.Enabled = Not IsNull(O6Vote) And Me.Level = "Level 3 Cat 2" Or Me.Level = "Software" And Me.[Soft Level] = "Level 3 Cat 2"
    Me.FinalVote.Enabled = Not IsNull(O6Vote) And (Me.Level = "Level 2") Or (Me.Level = "Software" And Me.[Soft Level] = "Level 2") Or Me.FinalVote.Enabled = Not IsNull(O6Vote) And (Me.Level = "Level 3 Cat 1") Or (Me.Level = "Software" And Me.[Soft Level] = "Level 3 Cat 1")
    End Sub

    Private Sub GOVote_BeforeUpdate(Cancel As Integer)
    Me.FinalVote.Enabled = Not IsNull(GOVote) And Me.Level = "Level 3 Cat 2" Or Me.Level = "Software" And Me.[Soft Level] = "Level 3 Cat 2"
    End Sub

    Everything works fine until I go to the next/previous or new record. All the fields I wanted disabled have become enabled.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    The Form_Load is missing End Sub - guessing that is just a posting error and code actually has that line.

    If these are textboxes you want to Enable/Disable, consider using Conditional Formatting.

    Is form in Single View?

    There is no Current event code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I missed the end sub. I'll fix that

    Form is single view and there is no current event code AFAIK. I do have embedded macros on the buttons.

    Conditional Formatting allows 3 changes to an field in Access 2007, which is what most use in my area. I don't think that would be sufficient to what I am trying to do. Just adding form control reset for enable=false on certain fields on the change of a record.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    The property settings should hold when moving to another record. Don't know why are not. If you want to provide db ...
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    As requested


  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    You need to run Debug > Compile. This will reveal several code errors, like:

    Private Sub CR_Numb_AfterUpdate()
    Private Sub CR_Numb_BeforeUpdate()


    and misplaced End Sub:
    Private Sub Attachment_Click()
    End Sub
    Dim MyDb As DAO.Database


    and undeclared variable: myRecipient


    Not getting the issue you describe. Once control is enabled, it remains enabled between records. Do you want that?


    I think it is suggested in your other thread not to use DLast.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    June7,
    Yes you suggested not to use Dlast in the other thread. MAX or Min is a range. I am not using a range AFAIK. I want to use the last record input to get its information. If MAX?MIN can get me what is in the previous record in a safer manner, please show me. All I have seen is that tis is a range function.

    I would look for the maximum number in the CR_No field? What about the Max number in the same record set for SUB_Num? That would change the max number.



    Once control is enabled, it remains enabled between records. Do you want that?

    No I want the control to revert back to original status when the next/previous or new record is opened

    Thanks for the compile heads up. The first issue was my cut-n-paste error, the last was something I was working on for later.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    What do you mean Max or Min is a range? Max and Min will return the maximum or minimum value of a given dataset, just as Last and First return the first or last of a given dataset. All domain aggregate functions (DMin, DMax, DFirst, DLast, etc.) can have filter criteria.

    Think you need code in the Current event to set controls back to their original open status.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I sit corrected. I had to change my base record numbers, but I got the dmax to work on CR_No. It won't work on Sub_No as I used this to numerate the base records.

    I'll try the current event idea and let you know.

    Update = Mission Complete.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 07-24-2014, 04:30 PM
  2. Replies: 11
    Last Post: 01-26-2012, 01:22 PM
  3. how to change the words on form status bar?
    By techexpressinc in forum Forms
    Replies: 4
    Last Post: 09-12-2011, 11:24 AM
  4. Resetting Record Source on Form
    By Cheshire101 in forum Programming
    Replies: 5
    Last Post: 05-05-2011, 08:52 AM
  5. Edit record in form with original entry shown
    By erknoebe in forum Access
    Replies: 5
    Last Post: 09-29-2010, 02:33 PM

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