Results 1 to 7 of 7
  1. #1
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142

    Msg Box In Report to open a specific form

    I have a report [rptReport1] that summarizes transactions from [frmTransaction1] which in turn is controlled by a table [tblTransactions] which use's trID autonumber as a field
    What I want to do is to place either a button or combo box on the Report.

    IF A Button
    When clicked I would like a Yes/No message box with an input area that I can enter an ID number.
    When Yes open the detailed form with the corresponding ID number entered.
    When No Cancel Event

    IF A COMBO BOX


    Enter an ID number in the combo box when I hit Enter
    The detailed form with the corresponding ID number opens.

    Is this possible?

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Both are possible.

    In first case you need InputBox, not MsgBox.
    Code:
    Dim txtTrID As String
        txtTrID = InputBox("Please enter ID (0 cancels)")
        If txtTrID = 0 Then
            DoCmd.OpenForm YourFormName, acNormal, , "trID=" & txtTrID & """", acFormReadOnly, acWindowNormal
        Else
            Exit Sub
        End If
    Similar with combo box. Use select query selecting trIDs from your table as row source for combo box. Use on change event to check trID number selected in combo box and to open your detailed form.

  3. #3
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Thanks however if I enter a number it gives me an error message "Run-time error 2494" "The action or method requires Form Name argument" I put the name of my form after DoCmnd. OpenForm.

    ??

  4. #4
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Here is the code I entered
    Code:
    Private Sub trID_Click()
    Dim txtTrID As String
        txtTrID = InputBox("Please enter ID (0 cancels)")
        If txtTrID = 0 Then
            Exit Sub
        Else
            DoCmd.OpenForm (frmTransactionsFinance), acNormal, , "trID=" & txtTrID & """", acFormReadOnly, acWindowNormal
        End If
    End Sub

  5. #5
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Should be:

    Code:
    DoCmd.OpenForm "frmTransactionsFinance", acNormal, , "trID=" & txtTrID & """", acFormReadOnly, acWindowNormal
    Also, read about DoCmd.OpenForm arguments so you know, what any of them means and you can choose ones, that you need for what you want to achieve.

  6. #6
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I replaced with the above code now I get "Run-time error '3075':" " Syntax error in string query expression 'trID=23". "
    23 is the number I typed inti the Input box?????

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    ..."trID=" & txtTrID & """",...

    should be

    ..."trID=" & txtTrID,...

    Read up on the ways different datatypes are treated (string, numeric, date) in code

    Also I think you should have 3 commas between the name of the form and the where parameter so as cyanidem suggests read up on docmd.openform

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

Similar Threads

  1. Open Form To Specific Tab
    By shoelesscraig in forum Modules
    Replies: 4
    Last Post: 12-22-2015, 01:56 PM
  2. Open Form To Specific Record From A Report?
    By shoelesscraig in forum Reports
    Replies: 6
    Last Post: 12-11-2015, 08:38 PM
  3. Open form with specific record
    By Lukael in forum Programming
    Replies: 14
    Last Post: 11-16-2015, 06:31 AM
  4. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  5. Open to specific form
    By ecpike in forum Forms
    Replies: 2
    Last Post: 06-12-2009, 08:32 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