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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save as Dialog Box appear 3 times when saving a text file from exe

Status
Not open for further replies.

33216CLC

Programmer
Aug 17, 2000
173
BS
Hi,

It is very odd, but while running the compiled version of my program, the save as dialog box works fine. However, when I run the executable version, it appears again when I click on Ok. I click OK again and it closes then appears again. The third time I click OK, it closes and does not appear again.

Why would this happen in the executable, and not withthe compiled version?

Thank,
Cooleen
[sig][/sig]
 
Here is the code, Simon.

Private Sub Export()
Dim Status As String
Dim PType As String
Dim Class As String
Dim rs As Recordset 'Payroll
Dim rsemp As Recordset
Dim sEmp As String
Dim sql As String


opendlg.Filter = "Text File (*.txt)|*.txt"
opendlg.FilterIndex = 0

opendlg.ShowSave
sFile = opendlg.FileName

If sFile = "" Then Exit Sub

Open sFile For Output As #1


sql = "select database1.* from database1 order by [Last], [First]"
Set rsemp = dbData.OpenRecordset(sql, dbOpenSnapshot)

If Not rsemp.BOF Then
While Not rsemp.EOF
If rsemp![Status] = "ACTIVE" Or rsemp![Status] = "Active" Then
Status = "A"
Else
Status = "T"
End If

With rsemp

If WITH_LABOUR Then
sEmp = FormatField(NullToStr(![Id_Num]), 10, "R") & FormatField(NullToStr(![Last]), 20, "L") & _
FormatField(NullToStr(![First]), 20, "L") & FormatField(NullToStr(![Middle]), 20, "L") & _
Filler(11) & Filler(10) & "F" & "H" & "S" & _
FormatField(NullToStr(![USER13]), 20, "L") & Filler(30) & Filler(30) & Filler(2) & Filler(5) & Filler(10) & _
FormatField(NullToStr(Status), 1, "L") & Filler(10) & Filler(10) & _
Filler(19) & "0"
Print #1, sEmp
Else
sEmp = FormatField(NullToStr(![Id_Num]), 10, "R") & FormatField(NullToStr(![Last]), 20, "L") & _
FormatField(NullToStr(![First]), 20, "L") & FormatField(NullToStr(![Middle]), 20, "L") & _
Filler(11) & Filler(10) & "F" & "H" & "S" & _
FormatField(NullToStr(![USER12]), 20, "L") & Filler(30) & Filler(30) & Filler(2) & Filler(5) & Filler(10) & _
FormatField(NullToStr(Status), 1, "L") & Filler(10) & Filler(10) & Filler(9) & "0"
Print #1, sEmp
End If
End With
rsemp.MoveNext
Wend
End If


Close #1


End Sub [sig][/sig]
 
Hi Simon,

Have you had the opportunity to look at the code I pasted?

Cooleen
 
Hi Cooleen,

I had the same problem some time back, but in Access-VBA (97).
When I called a function on a form from the menubar it called it 3 times. Microsoft told me they would have a look at it for $185, so I worked around it by calling a function in a global module from the menu and calling my form function from the global, and somehow this stopped the triple repetition!. I couldn't find the cause, most other menu functions were fine with about 4 menu functions with the problem. I don't know if this is related to what you have but the '3' seems a strange coincidence.

Michael
 
Thank you, Michael. It may not be related, but it is worth looking into.

Thanks alot,

Cooleen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top