PC Review


Reply
Thread Tools Rate Thread

Bad File Mode Access 2003, works fine on other PC

 
 
ToddRhodesECI
Guest
Posts: n/a
 
      17th Oct 2006
Hey guys. I have the following script:

Private Sub btnExportFile_Click()
'On Error GoTo Err_btnExportFile_Click


Dim Script1 As String
Dim strSQL1 As String
Dim strSQL1Output As String
Dim strSQL2 As String
Dim strSQL2Output As String
Dim strSQL3 As String
Dim strSQL3Output As String
Dim strSQL4 As String
Dim strSQL4Output As String
Dim strSQL5 As String
Dim strSQL5Output As String
Dim strSQL6 As String
Dim strSQL6Output As String
Dim strSQL7 As String
Dim strSQL7Output As String
Dim strSQL8 As String
Dim strSQL8Output As String
Dim strSQL9 As String
Dim strSQL9Output As String
Dim intFile As Integer
Dim SQLOutput As String
Dim db As Database, rs As ADODB.Recordset

Set rs = New ADODB.Recordset
strSQL1 = "Select * from Part1"
rs.Open strSQL1, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rs
While Not .EOF
strSQL1Output = rs!Part1
.MoveNext
Wend
.Close

End With
Set rs = Nothing
MsgBox ("Section 1 Complete...")

Set rs = New ADODB.Recordset
strSQL2 = "Select * from Part2"
rs.Open strSQL2, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rs
While Not .EOF
strSQL2Output = rs!Part2
.MoveNext
Wend
.Close

End With
Set rs = Nothing
MsgBox ("Section 2 Complete...")

Set rs = New ADODB.Recordset
strSQL3 = "Select * from Part3"
rs.Open strSQL3, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rs
While Not .EOF
strSQL3Output = rs!Part3
.MoveNext
Wend
.Close

End With
Set rs = Nothing
MsgBox ("Section 3 Complete...")

Set rs = New ADODB.Recordset
strSQL4 = "Select * from Part4"
rs.Open strSQL4, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rs
While Not .EOF
strSQL4Output = rs!Part4
.MoveNext
Wend
.Close

End With
Set rs = Nothing
MsgBox ("Section 4 Complete...")

If txtDivision = "" Then
txtDivision = Null
End If


Script1 = "insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('ADIServerName','" & txtCompanyCode & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('ADIDBName'
,'ADI_" & txtCompanyCode & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Pay_Group_ID','" & txtPayGroupID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('Shift_ID','"
& txtShiftID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Accrual_Group_ID','" & txtAccrualGroupID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Points_Group_ID','" & txtPointsGroupID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('Super_ID','"
& txtSuperID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Auto_Punch','" & txtAutoPunch & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Allow_Web_Entry','" & txtAllowWebEntry & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Paid_Holidays','" & txtPaidHolidays & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('Loc_ID','" &
txtLocID & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('Div_Code','"
& txtDivCode & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue) Values('Get_Rate','"
& txtGetRate & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('Card_Override','" & txtCardOverride & "')" & vbCrLf & _
"insert dbo.ADI_Defaults (ADI_Field,DefaultValue)
Values('DownloadRateToADI','" & txtDownloadRateToADI & "')" & vbCrLf &
_
"insert dbo.ADI_Departments (Loc_ID,Div_Code,Dept_Code,Position)
Values('" & txtLocation & "','" & txtDivision & "','" & txtDepartment &
"','" & txtPosition & "')" & vbCrLf & _
"insert dbo.ADI_Filter (EmpowerTable,EmpowerField,FilterValue)
Values('" & txtEmpowerTable & "','" & txtEmpowerField & "','" &
txtFilterValue & "')"

intFile = FreeFile
'Open "C:\" & txtCompanyCode & " - Integration Script.txt" For
Output As intFile
Open "\\eci-dzoflw13xtv\adi\test.txt" For Output As intFile
Print #intFile, strSQL1Output & vbCrLf & vbCrLf & Script1 & vbCrLf
& _
vbCrLf & strSQL2Output & vbCrLf & vbCrLf & strSQL3Output & vbCrLf &
vbCrLf & strSQL4Output

MsgBox (txtCompanyCode & " - Integration Script.txt Created!")
Close intFile

Exit_btnExportFile_Click:
Exit Sub

'Err_btnExportFile_Click:
' MsgBox Err.Description
' Resume Exit_btnExportFile_Click



End Sub



Private Sub btnCloseForm_Click()
On Error GoTo Err_btnCloseForm_Click


DoCmd.Close

Exit_btnCloseForm_Click:
Exit Sub

Err_btnCloseForm_Click:
MsgBox Err.Description
Resume Exit_btnCloseForm_Click

End Sub


If I try to run this on my work laptop (winXP SP2, Office 2003, just
updated today with all the latest updates for troubleshooting
purposes), I get an error: 54, Bad File Mode every time I try to run
it. I have tried writing to C:/, a new share on my machine with "Full
Control" access for Everyone, nothing seems to fix it.

If I run the same script at home (same specs, winXP2, Office 2003 just
recently updated), it works without a problem.

So, the syntax should be correct. I had my LAN administrator disable my
Kaspersky Anti-Virus for troubleshooting, but that didn't fix it. I can
run my laptop as local administrator and it still doesn't work. I
really need this to work but can't get it for the life of me. That it
works at home is great for letting me know that I wrote it correctly,
but it doesn't help me get my work done. If anyone can help out at all,
I'm willing to try anything. Thank you much for your time!


Todd Rhodes
Implementation Analyst, ECI Inc.

 
Reply With Quote
 
 
 
 
Phillip Windell
Guest
Posts: n/a
 
      17th Oct 2006
I am suspicious of this.....:

> Dim intFile As Integer
> intFile = FreeFile <<<<----this
> Open "\\eci-dzoflw13xtv\adi\test.txt" For Output As intFile <<<<---and
> this


........But I am not sure about it enough to suggest anything.

You could simplify the script a lot by just Dim'ing a single "strSQL" and
than dynamically concatinating the numerical digit on the end of "Select *
from Part1".
Like maybe:
---------------------------------------------------
Option Explicit
Dim i as Integer
Dim strSQL as String
Dim strSQLOutput as String

For i = 1 to 4 'Has 4 sections so loops 4 times
strSQL = "Select * from Part " & i
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
While Not .EOF '<<<---Loops the number of records in the Set
strSQLOutput = strSQLOutput & rs!Part '<<<---Adjust for that
somehow
rs.MoveNext
rs.Close
Wend
MsgBox ("Section " & i & " Complete...")
Next
Set rs = Nothing
-------------------------------------------------

It is off the top of my head and I'm sure it has errors to adjust for but
that gives the general idea.
This makes the script a *lot* shorter and easier to follow.

--
Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com

"ToddRhodesECI" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey guys. I have the following script:



 
Reply With Quote
 
ToddRhodesECI
Guest
Posts: n/a
 
      18th Oct 2006
That is a heck of a lot simpler. I don't have that much formal training
in any programming languages so I'm still learning some of the tricks
of the trade.

As for the portion of code you're suspicious of, I have tried
everything there, the standard is just "C:\test.txt" but I wanted to
try a share on my laptop with unlimited permissions, just to
troubleshoot the file system aspects of the problem.

Thank you very much for the suggestion, I will use your idea in the
code. I can't get better without good pointers like yours. Now if I
could just write to the darned file on my laptop .

Todd.

Phillip Windell wrote:
> I am suspicious of this.....:
>
> > Dim intFile As Integer
> > intFile = FreeFile <<<<----this
> > Open "\\eci-dzoflw13xtv\adi\test.txt" For Output As intFile <<<<---and
> > this

>
> .......But I am not sure about it enough to suggest anything.
>
> You could simplify the script a lot by just Dim'ing a single "strSQL" and
> than dynamically concatinating the numerical digit on the end of "Select *
> from Part1".
> Like maybe:
> ---------------------------------------------------
> Option Explicit
> Dim i as Integer
> Dim strSQL as String
> Dim strSQLOutput as String
>
> For i = 1 to 4 'Has 4 sections so loops 4 times
> strSQL = "Select * from Part " & i
> rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
> adLockOptimistic
> While Not .EOF '<<<---Loops the number of records in the Set
> strSQLOutput = strSQLOutput & rs!Part '<<<---Adjust for that
> somehow
> rs.MoveNext
> rs.Close
> Wend
> MsgBox ("Section " & i & " Complete...")
> Next
> Set rs = Nothing
> -------------------------------------------------
>
> It is off the top of my head and I'm sure it has errors to adjust for but
> that gives the general idea.
> This makes the script a *lot* shorter and easier to follow.
>
> --
> Phillip Windell [MCP, MVP, CCNA]
> www.wandtv.com
>
> "ToddRhodesECI" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hey guys. I have the following script:


 
Reply With Quote
 
ToddRhodesECI
Guest
Posts: n/a
 
      18th Oct 2006
An update:

In safe mode with no AntiVirus running, this works on my laptop. Not
sure if that helps anything, but I thought I should update as I found
new info, if for no other reason than future searches.

Also, I ran Filemon during the Export process, I get a lot of instances
of Kaskpersky AntiVirus opening files right after I execute the code so
I'm fairly certain my answer lies with Kaspersky. I'll have to do some
more troubleshooting with my LAN admin tomorrow with Kaspersky shut
off.

Thanks again and any other ideas are more than welcome!

ToddRhodesECI wrote:
> That is a heck of a lot simpler. I don't have that much formal training
> in any programming languages so I'm still learning some of the tricks
> of the trade.
>
> As for the portion of code you're suspicious of, I have tried
> everything there, the standard is just "C:\test.txt" but I wanted to
> try a share on my laptop with unlimited permissions, just to
> troubleshoot the file system aspects of the problem.
>
> Thank you very much for the suggestion, I will use your idea in the
> code. I can't get better without good pointers like yours. Now if I
> could just write to the darned file on my laptop .
>
> Todd.
>
> Phillip Windell wrote:
> > I am suspicious of this.....:
> >
> > > Dim intFile As Integer
> > > intFile = FreeFile <<<<----this
> > > Open "\\eci-dzoflw13xtv\adi\test.txt" For Output As intFile <<<<---and
> > > this

> >
> > .......But I am not sure about it enough to suggest anything.
> >
> > You could simplify the script a lot by just Dim'ing a single "strSQL" and
> > than dynamically concatinating the numerical digit on the end of "Select *
> > from Part1".
> > Like maybe:
> > ---------------------------------------------------
> > Option Explicit
> > Dim i as Integer
> > Dim strSQL as String
> > Dim strSQLOutput as String
> >
> > For i = 1 to 4 'Has 4 sections so loops 4 times
> > strSQL = "Select * from Part " & i
> > rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
> > adLockOptimistic
> > While Not .EOF '<<<---Loops the number of records in the Set
> > strSQLOutput = strSQLOutput & rs!Part '<<<---Adjust for that
> > somehow
> > rs.MoveNext
> > rs.Close
> > Wend
> > MsgBox ("Section " & i & " Complete...")
> > Next
> > Set rs = Nothing
> > -------------------------------------------------
> >
> > It is off the top of my head and I'm sure it has errors to adjust for but
> > that gives the general idea.
> > This makes the script a *lot* shorter and easier to follow.
> >
> > --
> > Phillip Windell [MCP, MVP, CCNA]
> > www.wandtv.com
> >
> > "ToddRhodesECI" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hey guys. I have the following script:


 
Reply With Quote
 
David F Cox
Guest
Posts: n/a
 
      18th Oct 2006
Kapersky creates a log file so someone could check that. It is just possible
that if automatic repair is in effect it could have detected a false
positive and "fixed" it. One of the techniques virus writers use is to
disguise code as data so no anti-virus program can be free of this sort of
error. In traing mode you get the chance to tell it which programs it has
not got to "fix", but that can be a frustrating process.


"ToddRhodesECI" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> An update:
>
> In safe mode with no AntiVirus running, this works on my laptop. Not
> sure if that helps anything, but I thought I should update as I found
> new info, if for no other reason than future searches.
>
> Also, I ran Filemon during the Export process, I get a lot of instances
> of Kaskpersky AntiVirus opening files right after I execute the code so
> I'm fairly certain my answer lies with Kaspersky. I'll have to do some
> more troubleshooting with my LAN admin tomorrow with Kaspersky shut
> off.
>
> Thanks again and any other ideas are more than welcome!
>
> ToddRhodesECI wrote:
>> That is a heck of a lot simpler. I don't have that much formal training
>> in any programming languages so I'm still learning some of the tricks
>> of the trade.
>>
>> As for the portion of code you're suspicious of, I have tried
>> everything there, the standard is just "C:\test.txt" but I wanted to
>> try a share on my laptop with unlimited permissions, just to
>> troubleshoot the file system aspects of the problem.
>>
>> Thank you very much for the suggestion, I will use your idea in the
>> code. I can't get better without good pointers like yours. Now if I
>> could just write to the darned file on my laptop .
>>
>> Todd.
>>
>> Phillip Windell wrote:
>> > I am suspicious of this.....:
>> >
>> > > Dim intFile As Integer
>> > > intFile = FreeFile <<<<----this
>> > > Open "\\eci-dzoflw13xtv\adi\test.txt" For Output As intFile
>> > > <<<<---and
>> > > this
>> >
>> > .......But I am not sure about it enough to suggest anything.
>> >
>> > You could simplify the script a lot by just Dim'ing a single "strSQL"
>> > and
>> > than dynamically concatinating the numerical digit on the end of
>> > "Select *
>> > from Part1".
>> > Like maybe:
>> > ---------------------------------------------------
>> > Option Explicit
>> > Dim i as Integer
>> > Dim strSQL as String
>> > Dim strSQLOutput as String
>> >
>> > For i = 1 to 4 'Has 4 sections so loops 4 times
>> > strSQL = "Select * from Part " & i
>> > rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
>> > adLockOptimistic
>> > While Not .EOF '<<<---Loops the number of records in the Set
>> > strSQLOutput = strSQLOutput & rs!Part '<<<---Adjust for
>> > that
>> > somehow
>> > rs.MoveNext
>> > rs.Close
>> > Wend
>> > MsgBox ("Section " & i & " Complete...")
>> > Next
>> > Set rs = Nothing
>> > -------------------------------------------------
>> >
>> > It is off the top of my head and I'm sure it has errors to adjust for
>> > but
>> > that gives the general idea.
>> > This makes the script a *lot* shorter and easier to follow.
>> >
>> > --
>> > Phillip Windell [MCP, MVP, CCNA]
>> > www.wandtv.com
>> >
>> > "ToddRhodesECI" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> > > Hey guys. I have the following script:

>
>



 
Reply With Quote
 
ToddRhodesECI
Guest
Posts: n/a
 
      18th Oct 2006
It's all fixed up now. Kaspersky was blocking macro's from opening
files for Write access and I was able to turn that off and run the
script successfully. I now know why it failed the last time my LAN
Admin turn off the AntiVirus, apparently you have to close down the
application (Access 2003 in my case) and reopen it for Kaspersky to
treat it according to the new policy. Otherwise, it just keeps blocking
the script.

Thanks for your help guys, I really appreciate it!

Todd.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with subform in Access 2007 - works fine in Access 2003 CinBar Microsoft Access Forms 5 4th Jan 2008 03:51 PM
Outlook 2007 can't open pst file that works fine in 2003 rfc Microsoft Outlook 10 23rd Nov 2007 08:26 PM
xls file works fine in Excel 2000 and 2007 but crashes on opening in 2003 gromit12 Microsoft Excel Misc 2 6th Nov 2007 09:30 PM
Syntax Error in Access 2003 but works fine in Beta 07 SteveC Microsoft Access Forms 4 2nd Jul 2006 04:33 PM
Win4Lin works fine on AMD64s in 32 bit mode. General Schvantzkoph AMD 64 Bit 0 25th Aug 2004 10:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 AM.