Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

when opening a form and no data is present runtime error 2757. Would like message box instead of error.

Posted on 2005-04-20
3
Medium Priority
?
284 Views
Last Modified: 2009-07-29
Hi  - I have a form that lists TMX_MgrTarget, which are employee numbers. There is a summary button that can be selected which opens another form (Frm_EmployeeSummary) and shows detail for this manager. if someone clicks on the open form where no manager exists (TMX_MgrTarget is null) , logically, I get a run-time error '2757' asking the user to end or debug. I would like a message box instead that states that no manager has been selected.  I am just not sure how to go about this.  

Here is the code that opens the Frm_EmployeeSummary:


Private Sub opensum_Click()
On Error GoTo Err_opensum_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Frm_EmployeeSummary"
   
    stLinkCriteria = "[TMXID]=" & Me![TMX_MgrTarget]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_opensum_Click:
    Exit Sub

Err_opensum_Click:
    MsgBox Err.Description
    Resume Exit_opensum_Click
   
End Sub


Any help would be greatly appreaciated.
0
Comment
Question by:plpking1
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Stephen_Perrett earned 2000 total points
ID: 13829991
Try

Private Sub opensum_Click()
On Error GoTo Err_opensum_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Frm_EmployeeSummary"
   
    stLinkCriteria = "[TMXID]=" & Me![TMX_MgrTarget]

me.refresh
if Not IsNull(Me!TMX_MgrTarget.value) Then
    DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
    msgbox "Please select Manager"
End if

Exit_opensum_Click:
    Exit Sub

Err_opensum_Click:
    MsgBox Err.Description
    Resume Exit_opensum_Click
   
End Sub

Steve
0
 

Author Comment

by:plpking1
ID: 13830372
Steve - most grateful. Worked like a charm. Thank you.
0
 
LVL 11

Expert Comment

by:Stephen_Perrett
ID: 13830556
That's great

Thanks for the points

Steve
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question