+ Reply to Thread
Results 1 to 22 of 22

disable command button once data is recorded

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    disable command button once data is recorded

    hi everyone,

    I am new with using excel vba and I need your expertise on this one. I am making a timesheet which has a UserForm with textbox and 3 command buttons namely Search, IN and OUT. The program works like this, user type his id no., then clicks on search, once id match command buttons for IN and OUT are enabled. User clicks on IN button then current time which tags as NOW() will be pasted on the worksheet. Same goes with the OUT button. I was able to make them work that way. The problem here now is, the data being entered are vulnerable for data-re entry. What I mean is, if a certain user has already a recorded IN time, if he clicks on the IN time again, the data will be overwritten. Is there a way that once the user has already a recorded IN time, the IN button will be disabled for that user since he has already a recorded IN data?

    I appreciate your assistance.


    Cheers,

    Stoey

  2. #2
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129
    Try this:

    PHP Code: 
    Private Sub CmdB1_Click()
    'Your code here
    ---------'
    CmdB1.Enabled False
    End Sub 

  3. #3
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362
    hi,

    I appreciate your immediately reply. I tried your code on the IN button, it work for the first user but, when the next user will use it, the IN button is disabled same goes to succeeding users. What I want to do is that once a specific user click the IN button and his time in was recorded or pasted on the worksheet, then the IN button will be disabled since he has already entered his time IN. But for other users who dont have time in record yet on the worksheet, the IN button should be enabled for them. Same goes for them OUT button.

    Any other ideas?

    cheers,

    Stoey

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your code should check if the user has an entry for that date in the cell & if it has exit the code.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362
    Hi roy,

    thanks for the idea but how am I suppose to do that? I am new with excel vba. Can you show me how? Thanks


    Cheers,

    Stoey

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I don't know what your existing code is, so I can't tell you how to code it. Post your code or attach the workbook so I can see exactly what you are doing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1