Results 1 to 15 of 15
  1. #1
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21

    Moving AccessDB to Windows Server 2008 R2 has broken database connection

    Our AccessDB used to be on Windows Server 2003 R2, and it has been moved to Windows Server 2008 R2.
    Access is 2010 32 bit.

    The code (see below) worked before and now it doesn't. Does anyone have any idea what I can do to make this work? Thank you!!
    P.S. I've modified it so that it doesn't do much, I have just been trying to get it to return rows.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Function Wrap_Detail()
    'CallingRoutine As Integer


    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String

    Set db = CurrentDb
    If CallingRoutine = 1 Then
    strSQL = "Select * From [Community_Detail1]"
    Close #1
    'Open the Text file for writing.
    strFileName = "CityDetail.txt"
    Open "\\Server\shared$\Information Technology\NAS ITDept\" & strFileName For Output As #1
    ElseIf CallingRoutine = 2 Then
    strSQL = "Select * From [Community_Detail2]"
    Close #1
    'Open the Text file for writing.
    strFileName = "CityDetail.txt"
    Open "\\Server\shared$\Information Technology\NAS ITDept\" & strFileName For Output As #1
    End If


    Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)




    With rs


    If .RecordCount = 0 Then
    Print #1, "Record Count = " & rs.RecordCount
    Else
    Print #1, "Record Count = " & rs.RecordCount
    End If
    End With




    With rs
    Do While Not rs.EOF
    Loop
    End With
    Close #1 'Close file.
    End Function

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is the dB split?
    If yes, is the path to the BE identical?
    If no, did you relink the FE to the BE?

    I modified your code = I added or changed lines in BLUE
    Code:
    Function Wrap_Detail()
        'CallingRoutine As Integer
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim strSQL As String
        Dim WF As Integer
    
        Set db = CurrentDb
    
        WF = FreeFile   'get the next free handle
    
        If CallingRoutine = 1 Then
            strSQL = "Select * From [Community_Detail1]"
            Close #WF      '<<--- don't really need this line
            'Open the Text file for writing.
            strFileName = "CityDetail.txt"
            '        Open "\\Server\shared$\Information Technology\NAS ITDept\" & strFileName For Output As #1
            Open "\\Server\shared$\Information Technology\NAS ITDept\" & strFileName For Output As #WF    'write to file
        ElseIf CallingRoutine = 2 Then
            strSQL = "Select * From [Community_Detail2]"
            Close #WF    '<<--- don't really need this line
            'Open the Text file for writing.
            strFileName = "CityDetail.txt"
            Open "\\Server\shared$\Information Technology\NAS ITDept\" & strFileName For Output As #WF
        End If
    
    
        Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
        With rs
            If .RecordCount = 0 Then
                Print #WF, "Record Count = " & rs.RecordCount
            Else
                Print #WF, "Record Count = " & rs.RecordCount
            End If
        End With
    
        With rs
            Do While Not rs.EOF
                Print #WF, rs.Fields(0)
                rs.MoveNext    '<<<---- necessary in recordset loops
            Loop
        End With
    
        rs.Close  'close recordset
    
        Close #WF    'Close text file.
    
        Set rs = Nothing
        Set db = Nothing
    
    End Function

  3. #3
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    Thanks for the updated code, it's better written. Unfortunately it did not help. Re your questions: nothing has changed except the db was moved from Windows Server 2003 to Windows Server 2008. Could it have to do with the references, that they were not properly configured after the move?
    Click image for larger version. 

Name:	References.png 
Views:	11 
Size:	89.6 KB 
ID:	23190

  4. #4
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    I'm not clear on what's broken yet.

    Mithril, is the code failing with an error code? Where is it failing? Does it execute but not output to your intentions?

    Thanks,

    Jeff

  5. #5
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    It executes, but the output file is blank except for the line "Record Count = 0" that was inserted in the first "with" statement. To me that means the there is something wrong with the database connection but I don't know what it is.
    Does it matter that the properties are for "Database2"? Thank you for your input!!
    Click image for larger version. 

Name:	Database2.PNG 
Views:	10 
Size:	41.1 KB 
ID:	23192

  6. #6
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    To be more clear, the only thing I'm after here is a record count of the number of rows in the tables above. I have verified that each table has about 100 rows.

  7. #7
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    And now I've confused myself even further. When I change the query from
    strSQL = "Select * From [Community_Detail1]"
    to
    strSQL = "Select count(*) From [Community_Detail1]"
    I get the result:
    Record Count = 1. So the problem getting the record count for the "select * etc..." couldn't be the db connection. Any suggestions welcome!

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What is the file extension on your Access file? Is it .adp?

  9. #9
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    accdb. Thanks!

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I am still not clear about how the DB is split and other questions that have already been asked.

    If the problem is querying a table, this problem seems to be solved. Is there another issue?

    How many files do you have? Is there a file that resides on the Server and several files that act as front end files, front end files on other computers?

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Once again:

    Is the dB split?

    If yes, is the path to the BE identical?

    If no, did you relink the FE to the BE?

  12. #12
    Mithril28 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    21
    I don't think it is split, but I will describe it for you. It is a single access database (accdb) with tables, queries, macros, a module1 and an autoexec, no outside files, or anything located outside this one file.
    When the code is run it uses "Set db = CurrentDb" so that it access the data in its' own database.

    I don't think there is a path to the backend in that case is there? It's self-contained?

    It is supposed to be querying a query, not a table, but no rows are returned in that case, I get a "RecordCount = 0" (Print #WF, "Record Count = " & rs.RecordCount)

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I don't think there is a path to the backend in that case is there? It's self-contained?
    If you only have one file, you do not have a split DB. It does not seem you have any problems and everything is working correctly. Let us know if you run into trouble later.

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So "Community_Detail1" and "Community_Detail2" are saved queries?

    If you open (execute) "Community_Detail1", are records returned?

  15. #15
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    Quote Originally Posted by Mithril28 View Post
    Code:
    strSQL = "Select count(*) From [Community_Detail1]" 
    
    Use this, then write rs.fields(0) to the file instead of rs.recordcount. I always let the DB engine do what it's best at.

    Jeff

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-23-2015, 07:06 AM
  2. Access 2002 Runtime on Windows Server 2008
    By kingcarol in forum Access
    Replies: 0
    Last Post: 08-23-2012, 06:56 AM
  3. Replies: 0
    Last Post: 04-25-2012, 07:59 AM
  4. Sending email on windows server 2008
    By Randy in forum Access
    Replies: 0
    Last Post: 03-20-2012, 08:35 AM
  5. Replies: 3
    Last Post: 07-15-2010, 05:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums