Results 1 to 6 of 6
  1. #1
    DefinitelyMaybe is offline Advanced Beginner
    Windows 10 Access 2002
    Join Date
    Dec 2020
    Posts
    54

    Two subroutines on Current Event

    Hi Everyone...

    I have an event On Current to requery a few fields (thank to Gicu's help). Now I also need to add another subroutine to On Current to enable fields if the record is new. How would the syntax look to combine (if possible)? Below shows what I have and what I will look to add.

    Thanks in advance,

    Eric


    What I currently have:
    Private Sub Form_Current()
    Me.CapitalID.Requery
    Me.TxtCapName.Requery
    End Sub

    What I am looking to add:
    If Me.NewRecord Then
    Me.BusUnit.Enabled = True
    Me.CapitalID.Enabled = True

    Else
    Me.BusUnit.Enabled = False
    Me.CapitalID.Enabled = False

    End If

  2. #2
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    827
    Code:
    Private Sub Form_Current()
    
    Me.CapitalID.Requery
    Me.TxtCapName.Requery
    
    If Me.NewRecord Then
    Me.BusUnit.Enabled = True
    Me.CapitalID.Enabled = True
    
    Else
    
    Me.BusUnit.Enabled = False
    Me.CapitalID.Enabled = False
    
    End If
    
    End Sub
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    DefinitelyMaybe is offline Advanced Beginner
    Windows 10 Access 2002
    Join Date
    Dec 2020
    Posts
    54
    Thanks Moke.... So you can continue to add code for different actions as long as it's within the Private Sub/End Sub?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,573
    Or the short version?
    Code:
    Private Sub Form_Current()
    
    With Me
      .CapitalID.Requery
      .TxtCapName.Requery
      .BusUnit.Enabled = .NewRecord
      .CapitalID.Enabled = .NewRecord
    End With
    
    End Sub
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  5. #5
    DefinitelyMaybe is offline Advanced Beginner
    Windows 10 Access 2002
    Join Date
    Dec 2020
    Posts
    54
    Thank you both!

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,573
    Some people don't like the method I used as at times it can be a bit cryptic. I though you might be interested in the method. Does it make sense to you?
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

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

Similar Threads

  1. On Current Event Question
    By JeRz in forum Programming
    Replies: 2
    Last Post: 10-19-2016, 09:41 AM
  2. cbo Issue and On Current Event
    By buckwheat in forum Access
    Replies: 10
    Last Post: 08-29-2013, 11:39 AM
  3. Fields with subroutines affecting others
    By Ruegen in forum Programming
    Replies: 2
    Last Post: 08-06-2013, 11:02 PM
  4. Information message on current event
    By justauser in forum Forms
    Replies: 5
    Last Post: 02-07-2012, 12:15 PM
  5. Transactions over multiple subroutines
    By jp2access in forum Programming
    Replies: 0
    Last Post: 08-30-2009, 10:34 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 - Senior Forums