Results 1 to 3 of 3
  1. #1
    xBirdman is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2020
    Posts
    2

    Type mismatch error on form closure - no calculations or data changes on form

    I am getting a Type Mismatch (Run-Time 13) error on a form close action. The continuous form pulls in a small group of related records that need to be checked/edited (by opening specific records on a single record form). The Close button Click() action runs two update queries (successfully) prior to the error. There are no other calculations and all the data are loaded/unloaded on other forms without a hitch. I cannot figure out why the error is being generated and am hoping someone can ask me the right question to trigger a resolution. My code is straightforward. I added line numbers so I could use ‘Debug.Print Erl’ in the error handling to find the dubious line, and it tells me it is line 30, on the form closure. I’ve added a bit more background below, in case it helps.





    Code:
    Private Sub btnCloseAllegs_Click()
    
     10 On Error GoTo Err_btnCloseAllegs_Click
    
    20 DoCmd.SetWarnings False
    22 DoCmd.OpenQuery "1qryUpdateAllegationCaseInfo"
    24 DoCmd.OpenQuery "2qryUpdateAllegationCaseInfo"
    26 DoCmd.SetWarnings True
    30  DoCmd.Close"frmDiffAllegationsCheck"
    40  DoCmd.OpenForm"frmAllegationChooseList"
     100 Exit_btnCloseAllegs_Click:
    
        Exit Sub
    110 Err_btnCloseAllegs_Click:
            MsgBoxErr.Description
            Debug.PrintErl
            ResumeExit_btnCloseAllegs_Click
     End Sub
    



    Background:
    I had a pretty straightforward macro that ran with OnClick()of a closeForm command button. The macro created some temporary variables to update other related records, then ran two separate saved queries to 1) update dates, and 2) update locations, then closed the current form, and opened the next form. Not all related records/fields always need to be updated, so I have a “lock” which is a Yes/No. If that field is “Yes” the first query updates the date fields, but not the locations for those records. If it is “No” the first query updates dates and the second updates locations. All that worked fine both before and after my changes.



    I inserted a subroutine that checks for “Yes” records and if they exist, pulls them to a new form so the user can verify the information for those records. I broke the macro described above into two sections. Before the subroutine, I set the tempVars and close the current form. If there are ‘Yes’ records, the subroutine opens. If not, or after they are updated and the user clicks to close the form, the second half of the macro runs: the 2 queries update dates and locations where appropriate, the form closes (*Error here), and the next form opens.


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Well, syntax on that line is wrong. In addition to lack of space and missing parameter, form name is in wrong argument.

    30 DoCmd.Close acForm, "frmDiffAllegationsCheck"
    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
    xBirdman is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2020
    Posts
    2
    Quote Originally Posted by June7 View Post
    Well, syntax on that line is wrong. In addition to lack of space and missing parameter, form name is in wrong argument.

    30 DoCmd.Close acForm, "frmDiffAllegationsCheck"
    Gracias! It is funny that it took me all afternoon to figure this out. I kept hoping for an email from this site letting me knowsomeone had found the issue but for some reason the site is acting really,REALLY glitchy for me. I can’t type directly into the message boxes because itdrops keystrokes every 1-2 letters, and it didn’t send your response via email(as I had set it to do).

    Thanks for the help. The lack of spaces was due to theglitchy site interface I’m having. I had to go through my whole copied messageand add spaces after pasting in. I didn’t catch the spacing problem in the codesection. My issue was missing the object type call as the first argument.


    Cheers


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

Similar Threads

  1. Replies: 7
    Last Post: 11-05-2019, 12:04 PM
  2. Replies: 8
    Last Post: 03-23-2018, 11:38 AM
  3. Type mismatch error in a form
    By B66 in forum Forms
    Replies: 29
    Last Post: 08-29-2016, 02:41 PM
  4. data type mismatch error
    By accessmatt in forum Queries
    Replies: 10
    Last Post: 09-24-2014, 05:43 PM
  5. Data type mismatch error
    By nigelbloomy in forum Programming
    Replies: 1
    Last Post: 08-01-2012, 09:19 AM

Tags for this Thread

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