Results 1 to 12 of 12
  1. #1
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40

    Enforcing a selection to open a second form

    Ok you all have been sooooo helpful! Hopefully this is the last thing I need to deal with on this database.



    I have a the two forms below, the first one opens the second one and limits the records that can be seen by the selection of the county and practice on the first form. The problem I am having is the user can skip selecting the County and Practice and open the second form for entry, I need to stop them and force a selection. Any Ideas? I included the code for the Add or Edit Offer Button, it is tied to the on click option. Thank you!


    Click image for larger version. 

Name:	Untitled.png 
Views:	13 
Size:	171.0 KB 
ID:	24073



    Click image for larger version. 

Name:	Untitled1.png 
Views:	13 
Size:	202.1 KB 
ID:	24074

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    My first comment is in regard to your naming convention. If you have to maintain this, or -especially if anyone but you has to maintain this- using names that describe the purpose of Comboboxes and buttons is extremely helpful.

    How would you rate
    Command3 with something like btnAddEditDataForCCRP

    You can check for the presence of a value in cboCounty and cboPractice before offering to Open second form.

    Along the lines, or similar functionality

    (untested air code for concept only)
    If Nz(me.cboCounty,"") ="" then
    msgBox --you must select a County
    end if
    If Nz(me.cboPractice,"") ="" then
    msgBox --you must select a Practice
    end if


    --only after selections have been made does the logic flow to open the second form.

  3. #3
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    Quote Originally Posted by orange View Post
    My first comment is in regard to your naming convention. If you have to maintain this, or -especially if anyone but you has to maintain this- using names that describe the purpose of Comboboxes and buttons is extremely helpful.

    How would you rate
    Command3 with something like btnAddEditDataForCCRP

    You can check for the presence of a value in cboCounty and cboPractice before offering to Open second form.

    Along the lines, or similar functionality

    (untested air code for concept only)
    If Nz(me.cboCounty,"") ="" then
    msgBox --you must select a County
    end if
    If Nz(me.cboPractice,"") ="" then
    msgBox --you must select a Practice
    end if


    --only after selections have been made does the logic flow to open the second form.

    I know things should be named better, I pick the database up form someone.

    Soooo were would I put this code?

    Thanks

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Who built the forms?
    Do you understand Events?

    Quick overview:

    You present a form to the user (Form1).
    On that form are Controls (combobox, button, .....)
    For each control, there are events -- things like load, open, before update, after update etc.(Different controls support different events)
    In the combo, let's pick cboCounty, if the user makes a selection, this triggers the afterUpdate event
    For the form generally, there are also events. One of which is BeforeUpdate. This is the last chance you have to interact with the form and data before it is updated. So, in the BeforeUpdate event you can check to see if each combo has a value (You're looking for a value that is NOT Null and not a zero length string.)
    If either or both are not valued, you send a message to the user and bypass opening the second form.
    Only if both combos have valid values do you open the second form.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This sounds like a search form.
    You provided a pic of the button code, so you might try putting the code orange suggested between the last DIM statement and the "stDocName statements.

  6. #6
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    Quote Originally Posted by ssanfu View Post
    This sounds like a search form.
    You provided a pic of the button code, so you might try putting the code orange suggested between the last DIM statement and the "stDocName statements.
    Thanks for the suggestion but it didn't work.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please provide a copy of the database in zip format.

  8. #8
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    [QUOTE=orange;314001]Please provide a copy of the database in zip format.[/QU

  9. #9
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    CRPAllocations_03152016.zip Hopefully this works

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I'm looking at your database Form.

    Have added code to require a selection in combo1 and combo22.
    I'm not sure what the other 2 buttons are intended to do as far as the comboboxes are concerned.

    ------>Look at the click event of command3.<----------

    I have modified the database -- event code for click event of Command3.
    Data base has the same name. Zip has the same name.
    Attached Files Attached Files

  11. #11
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    Quote Originally Posted by orange View Post
    I'm looking at your database Form.

    Have added code to require a selection in combo1 and combo22.
    I'm not sure what the other 2 buttons are intended to do as far as the comboboxes are concerned.

    ------>Look at the click event of command3.<----------

    I have modified the database -- event code for click event of Command3.
    Data base has the same name. Zip has the same name.


    This is perfect!!! You are my hero!! Thank you sooooo much!

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You are welcome. Happy to help. But this is just to prevent opening the second form.
    There may be other "issues" with your intended work flow, if users can bypass/skip steps.
    Better to make sure the user has followed your designed process --check the logic of your code etc.

    Good luck.

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

Similar Threads

  1. Replies: 3
    Last Post: 11-22-2015, 11:01 AM
  2. Relationship Many-to-Many (enforcing referential integrety)
    By Bigtonyicu@gmail.com in forum Access
    Replies: 1
    Last Post: 02-01-2013, 03:50 PM
  3. Replies: 3
    Last Post: 09-06-2012, 11:01 AM
  4. details form open from listbox selection
    By accesshelpme in forum Access
    Replies: 9
    Last Post: 05-18-2012, 10:50 AM
  5. Enforcing Data Accuracy from FK
    By Minerva in forum Access
    Replies: 3
    Last Post: 02-21-2010, 04:01 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