Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB code to disable save button after saving a form

VB code to disable save button after saving a form

Scheduled Pinned Locked Moved Visual Basic
saleshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13659767
    wrote on last edited by
    #1

    Please I will like to know if this code written is okay. seems to be having error. The aim is to prevent user from making any changes on form after saving.

    CUSTOMER RESERVATION BILLLING (cmdSave, Command2)
    If cmdSave.Caption = "Save" Then
    Adodc1.Recordset.AddNew
    txt.SetFocus
    'Disenablebuttons
    cmdsave.Enabled = True
    cmdAddNew.Caption = "Cancel"
    cboClassofRoom.Locked = False
    txtCustomer_Name.Locked = False
    txtRoomNo.Locked = False
    txtCustomer_Address.Locked = False
    txtPhone_number.Locked = False
    txtAmountPaid.Locked = False
    txtCheckin.Locked = False
    txtDuration.Locked = False
    txtDate.Locked = False
    txtReceptionist.Locked = False
    Else
    Adodc1.Recordset.CancelUpdate
    cmdsave.Enabled = False
    cmdAdd.Caption = "Add"
    'enablebuttons
    cboClassofRoom.Locked = True
    txtCustomer_Name.Locked = True
    txtRoomNo.Locked = True
    txtCustomer_Address.Locked = True
    txtPhone_number.Locked = True
    txtAmountPaid.Locked = True
    txtCheckin.Locked = True
    txtDuration.Locked = True
    txtDate.Locked = True
    txtReceptionist.Locked = True
    End IF
    End Sub

    D 1 Reply Last reply
    0
    • U User 13659767

      Please I will like to know if this code written is okay. seems to be having error. The aim is to prevent user from making any changes on form after saving.

      CUSTOMER RESERVATION BILLLING (cmdSave, Command2)
      If cmdSave.Caption = "Save" Then
      Adodc1.Recordset.AddNew
      txt.SetFocus
      'Disenablebuttons
      cmdsave.Enabled = True
      cmdAddNew.Caption = "Cancel"
      cboClassofRoom.Locked = False
      txtCustomer_Name.Locked = False
      txtRoomNo.Locked = False
      txtCustomer_Address.Locked = False
      txtPhone_number.Locked = False
      txtAmountPaid.Locked = False
      txtCheckin.Locked = False
      txtDuration.Locked = False
      txtDate.Locked = False
      txtReceptionist.Locked = False
      Else
      Adodc1.Recordset.CancelUpdate
      cmdsave.Enabled = False
      cmdAdd.Caption = "Add"
      'enablebuttons
      cboClassofRoom.Locked = True
      txtCustomer_Name.Locked = True
      txtRoomNo.Locked = True
      txtCustomer_Address.Locked = True
      txtPhone_number.Locked = True
      txtAmountPaid.Locked = True
      txtCheckin.Locked = True
      txtDuration.Locked = True
      txtDate.Locked = True
      txtReceptionist.Locked = True
      End IF
      End Sub

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Seriously? Did you even read your code?

      'Disenablebuttons (This should read DISABLE BUTTONS)
      cmdsave.Enabled = True ??????????

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Seriously? Did you even read your code?

        'Disenablebuttons (This should read DISABLE BUTTONS)
        cmdsave.Enabled = True ??????????

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        R Offline
        R Offline
        Ronnie Jimenez
        wrote on last edited by
        #3

        cmdsave.Enabled = False

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups