Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2006
    Posts
    73

    Unanswered: Do not close form if a text field is empty??

    Hey guys,

    I'm trying to set up a form that will require the user to enter in a required field, and if they click the close button if that text box is empty then it shouldn't close..I set up an if statement with the following if statement

    If Feedback_Date.Text = "" Then
    End(not sure if that'll just cancel the onClick command or not just tossed it in there for the sake of tossing it in. )
    Else
    DoCmd.Close
    End If

    is there something I'm missing in this? or should this work? cause I get an error saying I can't refrence a properity or method for a control unless the control has the focus..

    so any help would be great..

    thanks

  2. #2
    Join Date
    Jul 2005
    Posts
    144

    Cool try this

    I think the way i would do it is just simply change the required value of the text box to yes.

    I hope this helps

  3. #3
    Join Date
    Mar 2006
    Posts
    73
    Nope didn't work

    I wish ya could use C++ coding for these things lol my knowledge in VBA is very limited these days..heh

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Drop the ".Text", which you can only use if the control has focus. The default is ".Value", which is what you want anyway. You don't need the "End".
    Paul

  5. #5
    Join Date
    Mar 2006
    Posts
    73
    I've changed it to .Value, and added in a MsgBox and removed End

    now it's closing the form even if it's empty with no msgbox popping up heh

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Sorry, just noticed you're only testing for a zero length string, and you really need to test for Null.

    If IsNull(...) Then
    Paul

Posting Permissions

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