Results 1 to 4 of 4
  1. #1
    ntallman is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    7

    Unwanted Dialog Box

    Greetings o wise Access masters!

    I've created a search form using filters and have a button to take the user to the selected record in the data entry form. It works like a charm, but along with the data entry form I get a dialog box with the following message "The OpenForm action was cancelled". But it isn't, it opened just fine, so I'm confused. I'm using MS Access 2003 and below is the event procedure for the button. Any suggestions on getting rid of the dialog box?

    Thank you!


    Nathan

    Code:
    Private Sub Open_record_Click()
    On Error GoTo Err_Open_record_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "data_entry"
        
        stLinkCriteria = "[CONVERT_LNAME]=" & "'" & Me![CONVERT_LNAME] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        
        stLinkCriteria = "[CONVERT_FNAME]=" & "'" & Me![CONVERT_FNAME] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
        stLinkCriteria = "[RABBI_FNAME]=" & "'" & Me![RABBI_FNAME] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
        stLinkCriteria = "[RABBI_LNAME]=" & "'" & Me![RABBI_LNAME] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        
        stLinkCriteria = "[DATE]=" & "'" & Me![DATE] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        
    Exit_Open_record_Click:
        Exit Sub
    
    Err_Open_record_Click:
        MsgBox Err.Description
        Resume Exit_Open_record_Click
        
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You're attempting to open the same form 5 times. How many times is it actually opening? What is it you're expecting to see? The last one would probably be a problem, as date fields should be surrounded by #:

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ntallman is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    7
    It's only opening once and it selects the appropriate record, so that part works.

    I tried removing the all but the last "DoCmd.OpenForm stDocName, , , stLinkCriteria" statements, but nothing I would get the same error without the data entry form.

    Ah hah! I just replaced the " ' " with " # " around the date field per your suggestion and it works with no more dialog box!

    Thank you for your help Paul!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad it's working, though I'm not clear on why that works. I suspect you may want just one OpenForm line after:

    stLinkCriteria = "Condition1 AND Condition2 AND Condition3..."

    Personally I would also avoid the unnecessary concatenation, like the second instead of the first:

    stLinkCriteria = "[CONVERT_LNAME]=" & "'" & Me![CONVERT_LNAME] & "'"
    stLinkCriteria = "[CONVERT_LNAME]= '" & Me![CONVERT_LNAME] & "'"

    It won't make a big difference, but it is less efficient. Also, "Date" is a reserved word and shouldn't be used as a field name. Access can get confused between your field and the built-in Date() function. You can get away with it, but I'd change it if you're early in the process.

    Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Pop-up Dialog Box
    By DianeG in forum Reports
    Replies: 4
    Last Post: 03-29-2010, 09:51 AM
  2. Subform creating new unwanted entries
    By Rpatrick in forum Access
    Replies: 1
    Last Post: 08-14-2009, 03:08 PM
  3. How to restore Find dialog in Access
    By AndyKim in forum Access
    Replies: 11
    Last Post: 06-25-2009, 11:28 AM
  4. Common Dialog control / ShowOpen method
    By phuile in forum Forms
    Replies: 0
    Last Post: 04-10-2009, 12:16 AM
  5. dialog box errors in report
    By Jane in forum Programming
    Replies: 0
    Last Post: 11-20-2008, 01:06 PM

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