Problem with 2k not working on 2k3

Earthcoder

New member
Local time
Today, 05:58
Joined
Feb 5, 2007
Messages
2
Problem with access database in 2k not working on 2k3

Hello,

I have a access database here that was made many years ago in access 2000, We have upgraded all our users here to office 2003

But this users database wont export data comes up with the following msg

filenamenz6.png


The database is a frontend screen with a export button

I have been checking out the code but cant seem to work out what the issue is.


Top part of code.
Code:
Option Compare Database

       Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
       Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

       Private Type OPENFILENAME
         lStructSize As Long
         hwndOwner As Long
         hInstance As Long
         lpstrFilter As String
         lpstrCustomFilter As String
         nMaxCustFilter As Long
         nFilterIndex As Long
         lpstrFile As String
         nMaxFile As Long
         lpstrFileTitle As String
         nMaxFileTitle As Long
         lpstrInitialDir As String
         lpstrTitle As String
         flags As Long
         nFileOffset As Integer
         nFileExtension As Integer
         lpstrDefExt As String
         lCustData As Long
         lpfnHook As Long
         lpTemplateName As String
       End Type

Export part
Code:
Private Sub cmdExport_Click()

    On Error GoTo cmdExport_ClickErr
    Dim strEnrolfile As String
    Dim strCompletefile As String
    
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim sFilter As String
    OpenFile.lStructSize = Len(OpenFile)
    OpenFile.hwndOwner = Me.Hwnd
    OpenFile.hInstance = Me.Hwnd 'Application.hWndAccessApp '.hInstance
    sFilter = "Text (*.txt)" & Chr(0) & "*.txt" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrDefExt = "txt"
    OpenFile.lpstrFile = Me.txtUserName & "En.txt" & String(255, 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = "C:\"
    OpenFile.lpstrTitle = "Save Enrolment Data"
    OpenFile.flags = 4
    lReturn = GetSaveFileName(OpenFile)
    If lReturn = 0 Then
        strEnrolfile = "" ' User pressed the Cancel
    Else
        strEnrolfile = Trim$(OpenFile.lpstrFile)
    End If
    If strEnrolfile <> "" Then
        'MsgBox strEnrolfile
        DoCmd.TransferText acExportDelim, "EnrolmentExportSpecification", "EnrolmentExport", strEnrolfile, True
    End If
    
    OpenFile.lStructSize = Len(OpenFile)
    OpenFile.hwndOwner = Me.Hwnd
    OpenFile.hInstance = Me.Hwnd 'Application.hWndAccessApp '.hInstance
    sFilter = "Text (*.txt)" & Chr(0) & "*.txt" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrDefExt = "txt"
    OpenFile.lpstrFile = Me.txtUserName & "Completion.txt" & String(257, 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = ""
    OpenFile.lpstrTitle = "Save Completion Data"
    OpenFile.flags = 4 '256
    lReturn = GetSaveFileName(OpenFile)
    If lReturn = 0 Then
        strCompletefile = "" ' User pressed the Cancel
    Else
        strCompletefile = Trim$(OpenFile.lpstrFile)
    End If
    If strCompletefile <> "" Then
        'MsgBox strCompletefile
        DoCmd.TransferText acExportDelim, "CompletionExportSpecification", "CompletionExport", strCompletefile, True
    End If
    Exit Sub
cmdExport_ClickErr:
    MsgBox Err.Description, , Str$(Err.Number)
    
End Sub

I think it maybe something to do with the export part but i anything i try and change makes it worse.

Is there a way i can run the access file and when it comes up with error it shows me in code where error might be.


My knowledge of access coding is very limited i not used VB for about 7years or so.

Any help would be great or if you need more info just ask
 
Last edited:
My first idea would be try creating a nice blank access 2003 database. Then import all the items from the old one in to the new and see if that makes any difference.
 
Open you code and click in the margin on the right hand side. A red circle should appear. This is a breakpoint and the code will halt at this point. hoverver go back to you form and execute as normal. Once the de-bugger 'kicks in' you can then single-step until you hit the line in error.
Read up on de-bugging.
 
Thanks for all replys still cant seem to solve the issue.

I have done a custom install of Access2000 on the users pc so they have office 2003 software but access 2000 seems to work ok, hope it dont conflict much with office2k3
 

Users who are viewing this thread

Back
Top Bottom