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

    Command Button On Subform not working

    How can I execute a report if the combox "CbosupGPUser" is on Main Form "DepSlipMainFrm" and the command button "VDRCmd" is on Sub Form "DepSlipSubFrm"

    I am using the following code and its not working

    On Error GoTo Err_Handler

    Const ReportName = "CDBRpt"
    Const MESSAGETEXT = "No Bank Deposit ID # Selected."
    Dim strCriteria As String



    strCriteria = "[Deposit ID] = " & CbosupGPUser


    If Not IsNull(Me.CbosupGPUser) Then
    DoCmd.OpenReport ReportName, _
    View:=acViewPreview, _
    WhereCondition:=strCriteria
    Else
    MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"


    End If

    Exit_Here:
    Exit Sub

    Err_Handler:
    MsgBox Err.Description, vbExclamation, "Error"
    Resume Exit_Here


    End Sub

  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
    Try:

    strCriteria = "[Deposit ID] = " & Me.Parent.CbosupGPUser

    But why have button on subform if not using subform data to filter report?
    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
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thanks it works perfect

    On Error GoTo Err_Handler

    Const ReportName = "CDBRpt"
    Const MESSAGETEXT = "No Bank Deposit ID # Selected."
    Dim strCriteria As String



    strCriteria = "[Deposit ID] = " & Me.Parent.CbosupGPUser


    If Not IsNull(Me.Parent.CbosupGPUser) Then
    DoCmd.OpenReport ReportName, _
    View:=acViewPreview, _
    WhereCondition:=strCriteria
    Else
    MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
    End If

    Exit_Here:
    Exit Sub

    Err_Handler:
    MsgBox Err.Description, vbExclamation, "Error"
    Resume Exit_Here


    End Sub

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

Similar Threads

  1. Replies: 3
    Last Post: 03-15-2019, 06:05 PM
  2. Replies: 13
    Last Post: 01-22-2015, 05:27 PM
  3. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  4. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  5. Filter command not working for subform
    By yes sir in forum Access
    Replies: 15
    Last Post: 10-15-2010, 10: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