Results 1 to 10 of 10
  1. #1
    bjelinski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    13

    Disable the next record until the fields are field

    Dear all,

    I have a form that contains boxes with numbers (from a database), there are also decision boxes in a form that contain Target (Yes, No) (Combo32). Termination date & Reasons!
    The person must make a decision if the box with numbers is negative (Text29). I have used this code, and it works fine when you move your mouse to the combo 32! But still you can use the navigation button and go to next record (next customer)! My idea is to stop this! So when the number in Text29 is negative you can not move to next record until you fill the required fields!


    Private Sub Combo32_BeforeUpdate(Cancel As Integer)


    If Len(Me.Text29) > 0 Then
    If IsNull(Me.Combo32) Then
    Cancel = True
    MsgBox "You must make a decision in Target Customer field"
    End If
    End If
    End Sub

    Thanks in advance!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Assuming your controls are bound to fields in the RecordSource of the form, you can do your testing in the BeforeUpdate event of the FORM and Cancel any leaving of the record if you want. This works even if the user wants to close the form.

  3. #3
    bjelinski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    13
    thank you for the response. but i am not sure what you meant. i included this code to the form, but i still have the same effect!

    I am somehow trying to disable the next record and included it into this IF statement, but i dont know how.

    my next record button is the default code :

    Private Sub Next_Customer_Click()
    On Error GoTo Err_Next_Customer_Click
    Me.AllowAdditions = False
    DoCmd.GoToRecord , , acNext
    Exit_Next_Customer_Click:
    Exit Sub
    Err_Next_Customer_Click:
    MsgBox Err.Description
    Resume Exit_Next_Customer_Click

    End Sub

    now i want to say something like Next_Customer.Enable = False if the above statement is right (Text29 < 0 )


    thanks for any response

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You should really give your controls a more useful name than Text29. It makes it much easier to understand later when someone is trying to maintain the project. How many different tests need to me made in order to allow the user to advance to the next Customer?

  5. #5
    bjelinski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    13
    They need to give 3 decisions! 1st is yes/no (default is null), second is date, and third is free text (reason) , they all need to be filled if the field with number is negative.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Can you write this procedure in pseudo code? We could then help you convert it to VBA.

  7. #7
    bjelinski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    13
    Usually this form has a part that is informative and a part of decision making based on the informative part! On the top, in informative part, there is a field with numbers!

    However person doesn’t need to make a decision if the number in informative part (it could be 2 numbers) is positive! By default the person can click next button and go to next record (customer). The same effect is when the person clicks on the arrow at the bottom of the page and moves to the next record!

    Now the if statement should be, that if the number is < than zero, then next and previous record would be disabled with a message that says please fill the decision requirements (3 fields) , and when those fields are not null any more than the next & previous button is enabled…

    I hope it was clear!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Are there two controls with numbers that need to be added together if they have values in them?

  9. #9
    bjelinski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    13
    there are 2 fields with numbers that come directly from database!

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Something like:
    Me.cmdButtonName.Enable = Not ((Nz(Me.txtCtl1,0) + Nz(Me.txtCtl2,0)) < 0)
    ...in a procedure that is called in the AfterUpdates event of both txtCtl1 & txtCtl2 AND the CurrentEvent of the form should do it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Function to Enable/Disable Field
    By swalsh84 in forum Programming
    Replies: 5
    Last Post: 11-04-2010, 02:48 PM
  2. Replies: 3
    Last Post: 09-29-2010, 09:31 AM
  3. Replies: 1
    Last Post: 09-27-2010, 06:58 AM
  4. Disable fields based on another.
    By scottay in forum Forms
    Replies: 0
    Last Post: 08-10-2010, 05:40 PM
  5. disable/gray out fields
    By michaelpclisbee in forum Forms
    Replies: 2
    Last Post: 07-05-2009, 07:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums