Results 1 to 7 of 7
  1. #1
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27

    On-Click Event Procedure

    Hi all,

    I have a database that I am trying to recreate from an old one and have taken my code to use on a new form. I believe the problem is that my code is not executing since I have now included a message box. When I click on the button, I get nothing. Nothing happens. I did some searching and found that with MS Access 2007, you should be able to compile forms so that Access can determine where there might be errors but when I try to compile in the VB menu, the option is dimmed out. Additionally, I hear there is a requirement to "enable code" but when I try to view the URL for help from this forum, it never loads. My on-click event for the button does say "event procedure" and when I go to view the code, it takes me right to the procedure but then again, I don't have any other procedures in this database yet. Can you please help!!

    I am trying to add the entries of an unbound form into a table.

    Private Sub cmdAddNew_Click()
    On Error GoTo Err_cmdAddNew_Click
    Dim MyDB As Database, rcsDocControl As Recordset
    MsgBox "The Code is Executing!"

    Set MyDB = DBEngine.Workspaces(0).Databases(0)
    Set rcsDocControl = MyDB.OpenRecordset("tblDocControl")

    If Nz([txtDoc_ID], "") = "" Or Nz([txtTitle], "") = "" Or Nz([txtRevision], "") = "" Or Nz([txtDate_Added_DB], "") = "" _
    Or Nz([cboType], "") = "" Or Nz([cboOwner], "") = "" Or Nz([URL_Location], "") = "" Then
    MsgBox "You must complete all fields!", vbCritical, "Incomplete Record!"
    Exit Sub
    End If

    rcsDocControl.AddNew
    rcsDocControl![Doc_ID] = Forms![frmAddNewDoc]![txtDoc_ID]
    rcsDocControl![Title] = Forms![frmAddNewDoc]![txtTitle]
    rcsDocControl![Revision] = Forms![frmAddNewDoc]![txtRevision]
    rcsDocControl![Date_Added_DB] = Forms![frmAddNewDoc]![txtDate_Added_DB]
    rcsDocControl![Type] = Forms![frmAddNewDoc]![cboType]
    rcsDocControl![Owner] = Forms![frmAddNewDoc]![cboOwner]
    rcsDocControl![Location] = Forms![frmAddNewDoc]![URL_Location]
    rcsDocControl.Update

    MsgBox "The Document has been Added!", vbDefaultButton1, "Document Added!"

    txtDoc_ID = ""


    txtTitle = ""
    txtRevision = ""
    txtDate_Added_DB = ""
    cboType = ""
    cboOwner = ""
    URL_Location = ""

    Exit_cmdAddNew_Click:
    Exit Sub

    Err_cmdAddNew_Click:
    Select Case Err.Number
    Case 3022
    MsgBox "You have already added this controlled document (Document ID already in the database).", vbCritical, "Error!"
    Exit Sub
    Case Else
    MsgBox Err.Description & " " & Err.Number
    Resume Exit_cmdAddNew_Click
    End Select

    End Sub

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272

  3. #3
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27
    Thank you for the info Bob, the link did work. I am attempting to add one of my network drives as a trusted location and I get an error message that says:
    "The remote or network path you have entered is not allowed by your current security settings"
    Last edited by tbassngal; 07-13-2011 at 12:04 PM. Reason: Print screen didn't post

  4. #4
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27
    As an FYI: I was able to get my code to execute from the on-click event while the database is on a local drive but I plan to move this DB to a network share drive and will need that drive to be trusted to! Thanks so much for your help.

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Did you remember to check the check box that says:

    ALLOW TRUSTED LOCATIONS ON MY NETWORK (Not Recommended)



    But the frontend should be ON THE USER'S Computer not on a network location. The database should be split - backend (tables only) on the network location and the frontend (everything else) should be a COPY on EACH user's computer. Then it doesn't need the network trusted location check box checked. Multiple user databases should be set up with the copy of the frontend on each user's machine and not run from a network location.

  6. #6
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27
    Quote Originally Posted by boblarson View Post

    But the frontend should be ON THE USER'S Computer not on a network location. The database should be split - backend (tables only) on the network location and the frontend (everything else) should be a COPY on EACH user's computer. Then it doesn't need the network trusted location check box checked. Multiple user databases should be set up with the copy of the frontend on each user's machine and not run from a network location.
    You are so right, I don't know where my brain is today. Thank you for all your help.

  7. #7
    alam is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    1
    sir i am new with access i am making a data base for my institute i am using for data entry, i have problem to get remaing balance payment on payments entry form
    i have sum in my quey with field remaing balance.how do i get that remaing balance in text box on form when i enter the student ID

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

Similar Threads

  1. Replies: 1
    Last Post: 07-08-2011, 10:26 AM
  2. Replies: 4
    Last Post: 05-18-2011, 03:24 PM
  3. On Click Event Procedure
    By MrDean in forum Forms
    Replies: 3
    Last Post: 10-07-2009, 07:16 AM
  4. On-Click event transfer
    By nkenney in forum Forms
    Replies: 16
    Last Post: 03-26-2009, 09:02 PM
  5. Troubleshoot NotInList Event Procedure
    By skyrise in forum Programming
    Replies: 4
    Last Post: 02-23-2009, 06:06 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