Results 1 to 2 of 2
  1. #1
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125

    Cancel opening a form based on information

    I have a form for project information in which the primary key is manually entered. The command button I have set up to open this form filters the form to show only projects that the user is a part of. If a user isn't a part of any of the projects in the database this comes up as a blank new form.

    I'm trying to figure out some code to say "If user <> partofproject then do not open this form, msgbox 'you do not have any projects at this time'." (this is of course just an explanation).



    Here is the code to open the form if it helps:

    Private Sub butMyProjects_Click()
    DoCmd.OpenForm "frmProjectInfo", acNormal, , "Detailer1 = '" & Me.txtUser & "' OR Detailer2 = '" & Me.txtUser & "' OR Detailer3 = '" & Me.txtUser & "' OR Detailer4 = '" & Me.txtUser & "' OR Detailer5 = '" & Me.txtUser & "' OR Detailer6 = '" & Me.txtUser & "' OR Scheduler1 = '" & Me.txtUser & "' OR Scheduler2 = '" & Me.txtUser & "' OR OutsideDetailer = '" & Me.txtUser & "'", acFormEdit, acWindowNormal
    End Sub

  2. #2
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Nevermind, the point of this was to avoid the Primary Key Null error that my users would get when they would open a blank new record and try to leave it. I've figured out that DoCmd.RunCommand acCmdUndo attached to my back button is what I'm after.

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

Similar Threads

  1. Cancel form navigation event
    By tuna in forum Forms
    Replies: 3
    Last Post: 08-15-2010, 01:46 PM
  2. Replies: 3
    Last Post: 06-04-2010, 12:47 PM
  3. Replies: 3
    Last Post: 02-17-2010, 02:29 PM
  4. Replies: 4
    Last Post: 09-03-2009, 02:01 PM
  5. Replies: 4
    Last Post: 04-01-2009, 11:48 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