Results 1 to 3 of 3
  1. #1
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239

    switchboard not loading form

    hi, as per correspondence in this link: https://www.accessforums.net/forms/s...ems-46893.html


    I manually created a switchboard form and then, put below code, in the On_Click event of each button. The code is supposed to open a form once the login ID passes clearance but it is not loading the form. What am I doing wrong...?

    Develop and Administrator have AccessLevelID 1

    Dim CatID As Long
    Dim lUser As Long
    Dim UserLevel As Long


    If DLookup("AccessLevelID", "tblAccess", "UserID=" & Forms!frmLogin!cmbUser.Column(0) & "") <> 1 Then
    If IsNull(DLookup("UserID", "tblAccess", "CategoryID=122 AND UserID=" & Forms!frmLogin!cmbUser.Column(0) & "")) Then
    **If user not assigned to this category****
    MsgBox "You are not authorized to view this form"
    Cancel = True
    Else
    DoCmd.OpenForm "CardiacForm"
    With Me
    .DataEntry = True
    .AllowEdits = True
    .AllowDeletions = False
    .AllowAdditions = True
    .AllowFilters = False
    End With
    End If
    End If


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Have you step debugged? Do the DLookups return expected values? Is the combobox value actually the UserID? Refer to link at bottom of my post for debugging guidelines.

    The With Me code won't work. Me refers to form/report the code is behind, in this case the switchboard form, not the CardiacForm. If you want code behind switchboard form to modify CardiacForm, use:

    With Forms!CardiacForm

    Or

    Set the UserLevel variable and use it to pass value to CardiacForm with OpenArgs

    Do Cmd.OpenForm "CardiacForm", , , , , , UserLevel

    Code in CardiacForm Open event:
    If Me.OpenArgs <> 1 Then
    Me.DataEntry = True
    ...
    End If
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I believe this part of your code:

    With Me
    .DataEntry = True
    .AllowEdits = True
    .AllowDeletions = False
    .AllowAdditions = True
    .AllowFilters = False
    End With


    is actually referring to your switchboard form, not the form that is being opened, which I suspect is what you're actually trying to do. This may be returning focus to the switchboard, and I wonder if the form is actually being opened but is out of sight, behind the switchboard form.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. loading empty form
    By Suzie2012 in forum Forms
    Replies: 5
    Last Post: 10-10-2012, 07:03 PM
  2. Possible If statement for loading of a form
    By computer_man20037 in forum Programming
    Replies: 2
    Last Post: 05-16-2012, 09:53 AM
  3. Replies: 0
    Last Post: 02-15-2011, 01:43 PM
  4. Auto Loading a Form
    By toddbuckles in forum Programming
    Replies: 7
    Last Post: 12-28-2010, 04:20 PM
  5. Loading the form with selected record
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 12-09-2005, 07:49 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