Results 1 to 4 of 4
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Help Needed To Fix Code - Stop Debug Error Popup

    I am using the following code

    Private Sub ViewFrmPrintRptBtn_Click()
    On Error GoTo Forms



    If Not IsNull(ReportPrintList) Then

    DoCmd.OpenReport ReportPrintList, acViewPreview
    DoCmd.Close acForm, "DialogPrintFotm"
    Else
    'MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
    DoCmd.OpenForm ReportPrintList

    End If



    Exit_Here:
    Exit Sub

    Resume Forms



    Forms:
    DoCmd.OpenForm ReportPrintList



    DoCmd.Close acForm, "DialogPrintFotm"


    End Sub



    When Select Catagory is left Blank and / Or Select Forms Or Reports is also blank or not selected.

    View Form / Print Report
    is Cliked I am getting the following error
    Run-time error: '2498' Debug Error

    What should I add in the above mentioned code that this Debug Run-time error: '2498' should not pop-up.
    Instead A Message to pop up saying Select Catagory Can Not Be Left Empty And Select Forms Or Reports Must Be Selected To Proceed










    Click image for larger version. 

Name:	WoData.jpg 
Views:	17 
Size:	58.0 KB 
ID:	44372


    Click image for larger version. 

Name:	WithData.jpg 
Views:	17 
Size:	87.5 KB 
ID:	44373

  2. #2
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    When you post code. please use the code tags (the # in the reply menu)

    Without knowing you r object names are, it is hard to provide a focused reply.

    Would you please post your dB?




    BTW, the line "Resume Forms" does nothing and will never be executed.

    Code:
    DoCmd.Close acForm, "DialogPrintFotm"
    "Form" is misspelled.

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    How do you determine which is a report and which is a form?
    Do you have spaces and special characters in your object names?

    You need a column in your list that tells you if form or report or prefix your objects like frmSomething or rptSomething and use that to determine your docmd syntax.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Example using a column in listbox and also using the prefix of the object
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 1
    Last Post: 01-06-2018, 12:02 PM
  2. Help Debug code
    By joym in forum Access
    Replies: 6
    Last Post: 05-24-2017, 04:15 PM
  3. Replies: 15
    Last Post: 03-21-2017, 12:19 PM
  4. Form debug error
    By LOUM in forum Forms
    Replies: 5
    Last Post: 06-11-2012, 11:21 AM
  5. Is There a Way to Debug or Step Through VB code?
    By jeffbase34 in forum Programming
    Replies: 1
    Last Post: 05-28-2009, 08:14 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