Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Making a field not accessible

    Hello eveyone I have a little dilema, I need for a command button that leads to another form to be greyed out so that its not accessible to the user until he enters data (such as a time) in another field. so in order for the user to proceed to the next form they have to enter in data in another field they cant leave it blank. Does that make sense?? How exactly would I go about doing that??

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    desireemm, please do not cross post.
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    If IsNull(Me.<CertainField>.Value) Then
     MsgBox "Fill in <CertainField> or else!"
     Me.<ADifferentField>.Enabled = False
    Else
     Me.<ADifferentField>.Enabled = True
    End If
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    sorry

    Quote Originally Posted by georgev
    desireemm, please do not cross post.
    Sorry about that georgev

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Question

    Quote Originally Posted by georgev
    Code:
    If IsNull(Me.<CertainField>.Value) Then
     MsgBox "Fill in <CertainField> or else!"
     Me.<ADifferentField>.Enabled = False
    Else
     Me.<ADifferentField>.Enabled = True
    End If

    Would I be putting that code in the "On Exit" Event in the Command Button properties??

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Just fer the heck of it....

    While in Design View, be sure that the Command Button's Enabled property is set to False.

    Copy and paste the function below into your Form's Code module:

    Code:
    Private Function SetCommandEnable(Ctrl As Control, Cmd As Control)
       If IsNull(Ctrl) = True Then
          If Cmd.Enabled = True then Cmd.Enabled = False
       Else  
          If Cmd.Enabled = False then Cmd.Enabled = True
       End If
    End Function
    Now...place this line into both the OnCurrent AND OnMouseMove events of your Form:

    Call SetCommandEnable(Me.theFormControlNameWeNeedFilled, Me.myCommandButtonName)


    What this will do is this:

    1) When you go to a new record, the button will become disabled (since there will be no data in the Form control field in question).

    2) When the Form control field in question finally does contain data and the mouse is passed away from it then the Command button will become enabled.

    Now...you can of course forget about the OnMouseMove event and place the function call into the OnAfterUpdate even for the Form control field in question. That way, as soon as the field is updated and it does contain data the Command button will become either enabled or disabled. With either event, if the user enters data into the field then the button will become enabled but, it the user desides to delete the data within the same field during the same session then the button will autmatically become disabled.

    ahhhh...anywho....something like that
    Last edited by CyberLynx; 09-03-07 at 20:21.
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by CyberLynx
    Now...place this line into both the OnCurrent AND OnMouseMove events of your Form:
    Mouse move? So this event will fire every time the mouse moves when the form has focus? That's not a very efficient way of doing it!

    I suggest you sue the "On Got Focus" and "On Lost Focus" events of the form (form; not detail)
    George
    Home | Blog

  8. #8
    Join Date
    Nov 2003
    Posts
    1,487
    Quote Originally Posted by georgev
    Mouse move? So this event will fire every time the mouse moves when the form has focus? That's not a very efficient way of doing it!

    I suggest you sue the "On Got Focus" and "On Lost Focus" events of the form (form; not detail)

    georgev is right.....utilizing the MouseMove event is not a very efficient way of doing things which is why the SetCommandEnable Function requires the additional code (so as to eliminate screen flicker). The event should really be abolished from Access Forms all together. The one or two miliseconds it takes to fire the event has been known to be the root cause of suicide for some people especially when running MS-Access on a 486 Box.
    Environment:
    Self Taught In ALL Environments.....And It Shows!


Posting Permissions

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