Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBoxes not showing up

Status
Not open for further replies.

maxtin

Programmer
Dec 6, 2008
8
Hi, i have this very strange problem that occurs SOMETIMES with a software where you can use vba code.

When i run the code, msgboxes fail to show up and code is continuing through. I use this software (called RSView32 from Rockwell Automation) since couple of years now, and this is the first time i see this problem. The fix is simply by restarting the application but this is very annoying since msgboxes of type vbYesNo are getting "1 (vbOk)" automatically then the code continue on (like if someone acknowledged it). After I restart the application, it works fine for a while (msgboxes are popping normally) and then (seems randomly) you dont see them popping anymore.

I have two types of msgboxes in my code and both are affected:

1. Msgbox msg

2. Response = MsgBox(Msg, Style, Title, Help, Ctxt)


Anyone already saw/experienced this?

help please...i really need to solve this
 
Hi,

kKnda hard to imagine or guess what your code may look like.

Please post your code.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Private Sub Test()

On Error Goto Error

MsgBox "test"

exit sub

Error:

MsgBox "Error occured"

End Sub
 
I don't know the RSView32 application, so there may be something odd in it, but I would question whether perhaps, when it goes wrong, you have a file open that is somehow intercepting the MsgBox routine. What do you see when you single step through the code?

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
when i single step....the msgbox doest execute visually and the code continue to the next line returning VbOk.
 
Is there 'On Error Resume Next' somewhere? vbOk=1; what happens when you set response to 0 on startup and after executing message box?

combo
 
no, there is no 'Resume Next' statement in the subroutine. I know it returns VbOk since the following returns always returns '1'

Code:
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

Nothing is running in the background



 
My problem is that I don't see that line in your posted code. If you want help with code, it's best if you post the code.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Code:
Private Sub Test()

On Error Goto Error
 
 Dim Response as integer

 Response = MsgBox(Msg, Style, Title, Help, Ctxt)

 Exit sub

Error:

 MsgBox "Error occured"

End Sub

this does the same behavior
 
Null Msg, Style, Title, Help & Ctxt?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I don't know what the cause of your problem is but it is not in anything that you have so far posted. Maybe you have something else running that is interfering in some way. Do other msgboxes work?

Whatever it may be, I'm sorry to have to say that if you're not prepared, as a minimum first step, to post complete code that's actually failing, I can't really help you any more. I don't have a crystal ball and I can't see your environment.




Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
ok..here's the code

Code:
Private Sub Compare(ByVal SQLString As String, ByVal SQLString2 As String)
 
On Error GoTo error
 
   Dim cnDATA As ADODB.Connection
   Dim rsDATA2 As ADODB.Recordset
   Dim strConn As String
   Set cnDATA = New ADODB.Connection
 
   Dim QuestionMsg
 
 
If DtbConnError = False Then
   strConn = "PROVIDER=SQLOLEDB;"
   strConn = strConn & " DATA SOURCE= " & conDataSource & ";INITIAL CATALOG=" & conInitialCatalog & ";"
   strConn = strConn & " USER ID=" & conUserID & "; PASSWORD=" & conPassword
 
 cnDATA.Open strConn
 
End If
 
 
   Dim TagCol As Tags
   Dim temp As String
 
 
   Set TagCol = gTagDb.QueryForTags("TAG*", roIncludeAnalog)
 
   TagCol.ScanOn roWait
 
   Dim i As Single
      If Me.txtQty.Text <> "" Then
 
        i = CSng(Me.txtQty.Text)
 
        If i <> 0 Then
 
            'check if connection available
            If DtbConnError = False Then
 
                If Me.cmbIng.Text <> "" Then
 
                   Set rsDATA = New ADODB.Recordset
 
                    With rsDATA
                   .ActiveConnection = cnDATA
                   .Open SQLString
                    End With
 
                   If Not (IsNull(rsDATA("NumKey"))) Then
 
                     Dim HIng As Integer
                     HIng = TagCol.Item("TAG").Value
 
                        If HIng <> rsDATA("NumKey") Then
 
 
                            Set rsDATA2 = New ADODB.Recordset
 
                            With rsDATA2
                                 .ActiveConnection = cnDATA
 
                                 .Open SQLString2                                 
                            End With
 
                                 If IsNull(rsDATA2("Name")) Or rsDATA2.EOF = True Then
                                     temp = "unknown"
                                 Else
                                     temp = rsDATA2("Name")
                                 End If
 
                                 QuestionMsg = MsgBox("Are you sure?", vbYesNo, "Warning")
 
                                 Select Case QuestionMsg
                                     Case vbYes
                                      TagCol.Item("TAG").PendingValue = rsDATA("NumKey")
                                End Select
 
 
                         End If
 
                     End If
               End If
           End If
      End If
   End If
 
 Exit Sub
 
Error:
 MsgBox "Error"
End Sub
 
and...No...no msgboxes work after it fall into 'buggy mode'. Only fix is by restarting the application.
 
Again I ask: is that the actual code in your program that exhibits the behaviour; is it simply illustrative of code in your program that exhibits the behaviour; or is it an example that itself exhibits the behaviour?

 


Code:
Private Sub Compare(ByVal SQLString As String, ByVal SQLString2 As String)
 
On Error GoTo Error
...
FIRST statement...On Error.

ANY following statement that causes and error will go to Error.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
How wierd - when I posted my previous message the last post was skip's 13:28 message ... certainly when I posted I hadn't seen maxtin's code.
 
SKIP: it doesnt go there...it goes to the NEXT LINE

STRONGM: yes that is the code (my previosu post)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top