title: Ms access VBA - Select Case with MsgBox from module function
body: <p>Since one often uses one and the same message (i.e. error notes) on several forms in MS access, I thought about organizing all messages inside a table and call these with a public function:</p>
  
  <pre><code>Public Function message(msg_name As String, Optional msg_type As VbMsgBoxStyle)
  
  output =   MsgBox DLookup("Msg_Text", "vba_msg", "Msg_Name='" &amp; msg_name &amp; "'"), _
             msg_type, _
             DLookup("Msg_Caption", "vba_msg", "Msg_Name='" &amp; msg_name &amp; "'")
  </code></pre>
  
  <p>Plain and simple. Nicely working for simple notifications ("ouput = " and parentheses wouldn't be necessary for this, of course). However, I can't use these messages in a Select Case context:</p>
  
  <pre><code>Select Case message("test_message_name", vbYesNo)
    Case vbYes
      MsgBox "Yes"
    Case vbNo
      MsgBox "No"
  End Select
  </code></pre>
  
  <p>Neither pressing "Yes" nor "No" are recognized as such. I only get a response if I define "Case Else" as well.
  If I do the same procedure within one an the same Sub, everything works fine:</p>
  
  <pre><code>output =   MsgBox DLookup("Msg_Text", "vba_msg", "Msg_Name='" &amp; "test_message_name" &amp; "'"), _
             msg_type, _
             DLookup("Msg_Caption", "vba_msg", "Msg_Name='" &amp; "test_message_name" &amp; "'")
  
  Select Case output
    Case vbYes
      MsgBox "Yes"
    Case vbNo
      MsgBox "No"
  End Select
  </code></pre>
  
  <p>Am I missing something?</p>