Results 1 to 10 of 10
  1. #1
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Rules and Requirements in a Form

    Hi,



    I have a form with a number of fields on it. When the form is first created, a few of these fields are 'required' in the table definition. However, users will come back later & add further information into the form. I need to set a lot of rules around the fields to force the users to enter all required information. e.g. they can't enter 'offer 2' information until all 'offer 1' information has been entered. I tried to create a macro on the 'before event' of offer 2, but it didn't work because it's on the 'before event' you then can't navigate to the 'offer 1' field. I can use msgbox, to warn, but I really need to require the data entry rather than just warn. Any suggestions?

    By the way, I'm not good with VBA!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I don't use macros, only VBA.

    Code can manage the availability of controls on form. Set secondary controls Visible property to no. Then in AfterUpdate event of the primary control set the secondary as visible.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Thanks June7 - would you be able to show me how that code would look?

    Thanks in advance.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    In VBA: Me.controlname.Visible = True

    Set the AfterUpdate event property to [Event Procedure]. Double click the ellipses (...) and that will put you in the procedure in the VBA editor. Type code.

    There is probably a macro equivalent.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Thank you for that. I got the code working, but this still doesn't meet my needs because once the primary control has been updated, the secondary control is visable in all records, whether the primary control in that particular record Is Null or not.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    The form is in Single or Continous or Datasheet view?

    Put code in the Current event of form to set the Visible property to No. So that when you move to another record the control won't be available until primary is updated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Thumbs up

    Thanks so much, it is working perfectly.

  8. #8
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Sorry June - one last question if you have the time. I'm trying to now add additional code, and can't get it right. Can you please advise how my code should look? I currently have:

    Private Sub Form_Current()
    Me.Vacant_Pending_Development.Visible = False
    Me.Keys_To_Contractor.Visible = False
    End Sub

    However, it's not working. I tried 'And' but that didn't work either.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    'And' would not be appropriate.

    Which form is the Current event for?
    Which form are the controls on?
    Are those the actual names of the controls?

    I name bound controls different from the field they are bound to, like tbxKeys. That way I know whether I am referencing a field name or a control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Current Event and Controls are on the same form, and yes, they are the actual names of the controls (my controls are also named differently to my field names)

    On further investigation - you're right, I had the wrong control name. I now have it working. Thanks again for your help.

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

Similar Threads

  1. Report rules
    By paawian in forum Reports
    Replies: 1
    Last Post: 12-29-2011, 12:14 PM
  2. Field Rules
    By darrellx in forum Database Design
    Replies: 5
    Last Post: 08-21-2011, 07:31 AM
  3. System Requirements for Complex Large Queries
    By nguyeda in forum Import/Export Data
    Replies: 23
    Last Post: 08-04-2011, 01:30 PM
  4. Multiple Validation Rules in a form
    By GothardTech in forum Forms
    Replies: 1
    Last Post: 04-15-2011, 01:21 PM
  5. Importing Excel into Access with few requirements
    By pickolizac in forum Import/Export Data
    Replies: 1
    Last Post: 02-18-2009, 12:02 AM

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