Should be simple msgbox?

crich21

Registered User.
Local time
Today, 05:49
Joined
Jan 10, 2003
Messages
97
What am I missing. Can someone please tell me why my msgbox is being displayed twice. For example once I click on ok it pops up again and I have to hit okay again to make it go away. Also is there a way to make the msgbox a double line instead of one long line of text?


Private Sub PartNumber_DblClick(Cancel As Integer)
On Error GoTo Err_PartNumber_Click

Dim stDocName As String
Dim stLinkCriteria As String

If Me.UMID = 1 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 2 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 6 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 8 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 12 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 13 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 14 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 15 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 16 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 17 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 18 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 19 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 20 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 21 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 22 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 23 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 24 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 25 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 26 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 27 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 28 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 29 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 30 Then
GoTo Err_PartNumber_Click
ElseIf Me.UMID = 33 Then
GoTo Err_PartNumber_Click
End If

stDocName = "frmPartBreakDown"

stLinkCriteria = "[PartID]=" & Me![PartID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Const cQuote = """" 'Thats two quotes
Forms!frmPartBreakdown!PartID.DefaultValue = cQuote & Me!PartID.Value & cQuote

Exit_PartNumber_Click:
Exit Sub

Err_PartNumber_Click:
MsgBox "This unit of measure is not supported by the Part Breakdown Form. Please see designer for details.", vbInformation, "Information"
Resume Exit_PartNumber_Click

End Sub
 
I'm not sure why you're getting the MsgBox twice. Perhaps your code is encountering an error along the way as well as hitting a UMID number that sends the code to the error handling section.

I personally wouldn't handle the code this way. I reserve the error handling for actual code errors, not for "normal" code situations.

I'd shorten the syntax to use a select case structure. Like this:
Code:
Select Case Me.UMID
    Case 1, 2, 6, 8, 33, 12 To 30
    Case Else
End If
To separate a MsgBox line add a vbCrLf to the line, like this:
Code:
MsgBox "This unit of measure is not supported by the Part Breakdown Form." & vbCrLf & "Please see designer for details."
 
Last edited:
dcx693 said:
I'm not sure why you're getting the MsgBox twice. Perhaps your code is encountering an error along the way as well as hitting a UMID number that sends the code to the error handling section.

I personally wouldn't handle the code this way. I reserve the error handling for actual code errors, not for "normal" code situations.

I'd shorten the syntax to use a select case structure. Like this:
Code:
Select Case Me.UMID
    Case 1, 2, 6, 8, 33, 12 To 30
    Case Else
End If
To separate a MsgBox line add a vbCrLf to the line, like this:
Code:
MsgBox "This unit of measure is not supported by the Part Breakdown Form." & vbCrLf & "Please see designer for details."

Thank you for the response. Your answer is very beneficial. I have read about the case statement but not enough to implement it. This looks terribly easy compared to all the if then elseif that I have done. Thanks Again. Maybe that will correct my msgbox being displayed twice. Fingers crossed.
 

Users who are viewing this thread

Back
Top Bottom