Solved

Build Problems

Posted on 2002-06-14
9
133 Views
Last Modified: 2010-05-02
I have my app talking with SQL Server....

It works perfectly when I run it in build mode but then when I create the exe it hangs in various places such as after doing a recordset .update, it is supposed to display a message box.  In the build "run" it works, but in the .exe build it hangs where it should be displaying the message.

Any ideas?
0
Comment
Question by:baddogi
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:toys032498
ID: 7078662
Try putting a DoEvents prior to the message box.

0
 

Author Comment

by:baddogi
ID: 7078669
I've narrowed it down to the following code that is causing this:

'Msg = "Are You Sure You Want To Add This Department?"
'Style = vbYesNo + vbDefaultButton2
'title = "Confirmation"
'response = MsgBox(Msg, Style, title)


If I unrem this it hangs.....

Ideas?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 7078798
What code runs just before this?

mlmcc
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:baddogi
ID: 7078822
Here is the actual sub...

Sub Save_Click()

On Error GoTo errmsg:

Msg = "Are You Sure You Want To Add This Department?"
Style = vbYesNo + vbDefaultButton2
title = "Confirmation"
response = MsgBox(Msg, Style, title)
    If response = vbYes Then

    If txtdepartment.Text = "" Then
        MsgBox "Please Enter a Department Name"
    Exit Sub
    End If


With RS

.AddNew

!department = txtdepartment.Text


.Update

End With

MsgBox "Add Succeeded", vbOKOnly, "Status"
lblnew.Visible = False
txtdepartment.Visible = False

lblselect.Visible = True
combodepartment.Visible = True

ElseIf response = vbNo Then
lblnew.Visible = False
txtdepartment.Visible = False

lblselect.Visible = True
combodepartment.Visible = True
RS.Filter = adFilterNone
txtdepartment.Text = ""

Exit Sub
End If

Exit Sub

errmsg:

     MsgBox "Error # " & Str(Err.Number) & Chr(13) & Err.Description
         
Exit Sub
End Sub
0
 

Author Comment

by:baddogi
ID: 7078895
Here is the actual sub...

Sub Save_Click()

On Error GoTo errmsg:

Msg = "Are You Sure You Want To Add This Department?"
Style = vbYesNo + vbDefaultButton2
title = "Confirmation"
response = MsgBox(Msg, Style, title)
    If response = vbYes Then

    If txtdepartment.Text = "" Then
        MsgBox "Please Enter a Department Name"
    Exit Sub
    End If


With RS

.AddNew

!department = txtdepartment.Text


.Update

End With

MsgBox "Add Succeeded", vbOKOnly, "Status"
lblnew.Visible = False
txtdepartment.Visible = False

lblselect.Visible = True
combodepartment.Visible = True

ElseIf response = vbNo Then
lblnew.Visible = False
txtdepartment.Visible = False

lblselect.Visible = True
combodepartment.Visible = True
RS.Filter = adFilterNone
txtdepartment.Text = ""

Exit Sub
End If

Exit Sub

errmsg:

     MsgBox "Error # " & Str(Err.Number) & Chr(13) & Err.Description
         
Exit Sub
End Sub
0
 
LVL 4

Expert Comment

by:gencross
ID: 7079169
I think maybe your variable names are causing this.  I do not see any DIMs and Style is a keywork.  Try something like this...

Sub Save_Click()

Dim sMsg as string
Dim vStyle
Dim sTitle as string
Dim iResponse as integer

On Error GoTo errmsg:

sMsg = "Are You Sure You Want To Add This Department?"
vStyle = vbYesNo + vbDefaultButton2
sTitle = "Confirmation"
iResponse = MsgBox(sMsg, vStyle, sTitle)
0
 
LVL 4

Accepted Solution

by:
gencross earned 200 total points
ID: 7079174
I mean Style is a VB Keyword.  Whether or not this is the solution to your problem it is always good programming practice to prefix your variable names.  There are different naming conventions you can use :)
0
 
LVL 1

Expert Comment

by:toys032498
ID: 7079753
Nice job gencross!  I totally over looked that.

Thats why you should always use the following in the begining of every module.

Option Explict
0
 
LVL 4

Expert Comment

by:gencross
ID: 7083486
Thanks.  This one is easy to miss, and Option Explicit is the way to go:)

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Script Host failed (Access is denied.) error 6 243
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 59
Help me. 3 60
MS SQL Update query with connected table data 3 41
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 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