Results 1 to 4 of 4
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    Unhappy Open Report based on the current record selected on the form


    In my current form (frmRequests) I have a button as an option for the user to View/Print the current record. Following is my code, however it opens the report with no data.

    Code:
    Private Sub bVwRq_Click()
     
        bSave = True
        If Me.Dirty Then
            Me.Dirty = False 
        End If
       
        DoCmd.SetWarnings False
          
        DoCmd.OpenReport "rptViewEst", acViewReport, "", "[txtProjectNumber]=[Forms]![frmRequests]![txtProjectNumber]", acNormal
     
        DoCmd.SetWarnings True
     
     
    End Sub
    It worked before, but I don't what Access ghost broke it.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    try

    DoCmd.OpenReport "rptViewEst", acViewReport, "", "[txtProjectNumber]=" & me.[txtProjectNumber], acNormal

  3. #3
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    Thank you!

  4. #4
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Code:
     On Error Resume Next
    
    
     	Dim strReportName As String
        	Dim strCriteria As String
    
    
        If NewRecord Then
            MsgBox "Msg" 
    
    
            Exit Sub
        Else
        On Error Resume Next
    
    
            strReportName = "ReportName"
            strCriteria = "[ID]= " & Me![ID]
    
    
            DoCmd.OpenReport strReportName, acViewReport, , strCriteria
            DoCmd.RunCommand acCmdPrint
            DoCmd.Close acReport, "MastrRpt_internal", acSaveYes
    
    
    	End If

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

Similar Threads

  1. Replies: 2
    Last Post: 03-13-2016, 02:01 PM
  2. Replies: 3
    Last Post: 11-22-2015, 11:01 AM
  3. Replies: 3
    Last Post: 02-06-2015, 01:18 PM
  4. Replies: 9
    Last Post: 09-17-2013, 11:08 PM
  5. Replies: 2
    Last Post: 04-02-2013, 02:24 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