Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Unanswered: Force entry in centain filed if date is filled in one field

    How can make or use a pop up when certain fields need to be populated?

    For example:

    1. Please open the attached database.
    2. Open the form (frm_groups)
    3. The first tab "Census"
    4. When end user put a date in "1st Reject Date" then they must put a reason in "1st Reject Reasons". I want system to pop a window with some kinda warning that they or end user must enter some value or reasons in the reason bucket. and same theory applies to 2nd reject and 3rd reject.

    I hope I am clear.

    THANKS A MILLION.....
    Last edited by doran_doran; 09-16-03 at 01:27.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ooooops!
    i get a permissions problem opening your mdb
    izy

  3. #3
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    It's a zip and access 97 files.

    It's not encrypted with password. so you should not have trouble. Try deleting your old one and download the database again. SORRY.

  4. #4
    Join Date
    Apr 2003
    Posts
    5
    Create an after update event on the reject date field that displays a messagebox:

    Private Sub Ctl1st_reject_date_AfterUpdate()
    MsgBox "Do not forget to enter a reject reason.", vbOKOnly + vbInformation
    End Sub

    Always showing this box when a user enters a value in the reject date field seem very intrusive and annoying to me.

    It is probably better to put a before update event on the form that checks if all required data is entered. When you want to use this method you have to disable the close button in the control box of the form and change the code of your own close button to first check the validity of your data before closing the form.
    When you close the form the before update event is triggered but setting the cancel argument to true does not stop closing the form.

  5. #5
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Excellent...

    1. It worked, but like u said I need to take off the "close" button. and put somekinda code for final check on the data. How do I do that?

    Thanks for helping me. I was really frustrating myself but you guys are great pulling me from this situation.

    Thanks a million.

  6. #6
    Join Date
    Apr 2003
    Posts
    5
    The close button is disabled using the form properties:

    Open the form in design view
    View -> Properties
    On the format tab change the "Close Button" property to No

    -----------------------

    Add the following function to the class module of your form:

    Code:
    Private Function dataOK() As Boolean
    
      'Assume success
      dataOK = True
      
      'Now test reject reasons
      If Nz(Me![1st_reject_date], "") <> "" And Nz(Me![1st_rjct_reason], "") = "" Then
        MsgBox "You have not entered the first reject reason", vbOKOnly + vbExclamation
        dataOK = False
      ElseIf Nz(Me![2nd_rjct], "") <> "" And Nz(Me![2nd_rjct_reason], "") = "" Then
        MsgBox "You have not entered the second reject reason", vbOKOnly + vbExclamation
        dataOK = False
      ElseIf Nz(Me![3rd_rjct], "") <> "" And Nz(Me![3rd_rjct_reason], "") = "" Then
        MsgBox "You have not entered the third reject reason", vbOKOnly + vbExclamation
        dataOK = False
      End If
    End Function
    Change the click event on your close button to:

    Code:
    Private Sub close_Click()
    On Error GoTo Err_close_Click
    
        If dataOK = True Then DoCmd.close
    
    Exit_close_Click:
        Exit Sub
    
    Err_close_Click:
        MsgBox Err.Description
        Resume Exit_close_Click
        
    End Sub
    and add a before update event to the form:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
      Cancel = not dataOK
    End Sub
    Last edited by heer2351; 04-24-03 at 18:06.

  7. #7
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    ERROR...

    I am getting following error message. .....

    "Object doesn't support this property or method."

    I am using Access 97. Please see attached Database.
    Last edited by doran_doran; 09-16-03 at 01:27.

  8. #8
    Join Date
    Apr 2003
    Posts
    5
    doran_doran

    You misunderstood my post. The dataOK function should be in the code behind the form. This is in fact a class module.

    I have changed your database see attached.

    I also fixed a small flaw in my function, I used the wrong names for your second and third reject date and reason. It is now working fine.
    Attached Files Attached Files

  9. #9
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Thanks....

    IT WORKS. I JUST DID NOT KNOW HOW TO INSERT A CLASS CODE.

    THANKS A BILLION.........

Posting Permissions

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