Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Posts
    30

    Unanswered: Problems with disabling...

    I have a field that i need to have disabled when the user enters info into it. It accepts a number (which is a required field) that is used to determine how many rows to insert into a table and then display on the next form that opens. After they are created, when the button on the first form is clicked, instead of creating new records, it retrieves the ones created the first time. Therefore, changing this number on the first form will have no effect on the number of rows created in the table. I want to gray out the text field *only if/after* the user has entered that number. For some reason, when I tried
    Private Sub txtLayers_AfterUpdate()
    ' If txtLayers > 0 Then
    ' ActualSpcWdth.SetFocus
    ' txtLayers.Enabled = False
    ' End If
    End Sub


    it grays out this field on *all* records... even the ones that are either blank or have 0's. (some were able to be created without entering this field because I didn't make it required until later)

    Right now, I have this:

    Private Sub txtLayers_BeforeUpdate(Cancel As Integer)
    If txtLayers > 0 Then
    MsgBox "Number of Layers has been previously created and cannot be changed"
    Me.Undo
    End If
    End Sub


    I dont like that the user is not alerted until after they have entered the new number. I would rather them be able to see that it is not editable once the number is in there. Any suggestions as to how to do this and/or why the first code above is not working?

    Thanks!
    Seren

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If your Access version is 2000 or later, you can accomplish this with conditional formatting.
    Paul

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,418
    Provided Answers: 7
    Code:
    if newrecord then
    txtLayers.Enabled = True
    end if
    put it in the current event
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  4. #4
    Join Date
    May 2006
    Posts
    30
    Thank you... that's what I needed

  5. #5
    Join Date
    May 2006
    Posts
    30
    Well, this did work. And now it doesn't. Im extremely irritated. I "fix" one thing, and break something I spent a while "fixing" before that...

Posting Permissions

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