Results 1 to 5 of 5
  1. #1
    jsbotts is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Aug 2011
    Location
    Hobbs, NM
    Posts
    14

    Runtime Error 3027

    Using the following code I get Runtime Error 3027; Object is Read Only:

    Private Sub FixCC_To_Hospice()
    On Error GoTo PROC_ERR

    Dim cd As DAO.Database
    Dim rs As DAO.Recordset
    Dim SQL As String
    Dim rc As Integer

    SQL = "SELECT P.PatientID, P.CC_OriginalStatus, P.CC_CurrentStatus, A.PatientID, A.AdmissionID, A.CurrentCC_Status, A.DateOfAdmission " & _
    "FROM tblPatientInformation P, tblAdmissions A " & _


    "WHERE (P.PatientID = A.PatientID) AND (P.CC_OriginalStatus = 'NTUC') " & _
    "ORDER BY P.PatientID, A.DateOfAdmission"

    Set cd = CurrentDb()
    Set rs = cd.OpenRecordset(SQL, dbOpenDynaset)

    If rs.EOF = False Then
    rc = rs.RecordCount
    Debug.Print "Record count: " & rc
    Else
    MsgBox "No records found!", vbOKOnly + vbInformation, "No records found..."
    Exit Sub
    End If

    rs.MoveFirst
    Dim found As Boolean
    found = False
    Dim pn1 As String
    Dim pn2 As String
    Dim cs1 As String
    Dim cs2 As String
    Do While rs.EOF = False
    cs1 = rs("CurrentCC_Status").Value
    pn1 = rs("A.PatientID").Value
    rs.MoveNext
    cs2 = rs("CurrentCC_Status").Value
    pn2 = rs("A.PatientID").Value
    If pn1 = pn2 And found = False Then
    If cs1 = "NTUC" And cs2 = "CC(Live Discharge) -> O-VC Hospice" Then
    found = True
    rs.Edit
    rs("CurrentCC_Status").Value = "CC(NTUC) -> O-VC Hospice"
    rs.Update
    End If
    Else
    If pn1 <> pn2 Then
    found = False
    End If
    End If
    rs.MoveNext
    Loop

    rs.Close
    Set rs = Nothing
    Set cd = Nothing

    PROC_EXIT:
    Exit Sub
    PROC_ERR:
    MsgBox Err.Description
    Resume PROC_EXIT
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you mean to put:
    "FROM tblPatientInformation As P, tblAdmissions As A " & _

  3. #3
    jsbotts is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Aug 2011
    Location
    Hobbs, NM
    Posts
    14
    Yes I do mean As P and As A, but changing that code made no difference. Thanks for the reply.

  4. #4
    jsbotts is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Aug 2011
    Location
    Hobbs, NM
    Posts
    14
    Changing the SQL to use INNER JOIN worked:

    SQL = "SELECT P.PatientID, P.CC_OriginalStatus, P.CC_CurrentStatus, A.PatientID, A.AdmissionID, A.CurrentCC_Status, A.DateOfAdmission " & _
    "FROM tblPatientInformation P INNER JOIN tblAdmissions A ON P.PatientID = A.PatientID " & _
    "WHERE (P.CC_OriginalStatus = 'NTUC') " & _
    "ORDER BY P.PatientID, A.DateOfAdmission"

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for posting back with your success.

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

Similar Threads

  1. Runtime Error 3021
    By paddon in forum Programming
    Replies: 12
    Last Post: 03-14-2011, 12:14 PM
  2. Error in Runtime Only
    By drunkinmunki in forum Programming
    Replies: 7
    Last Post: 12-16-2010, 03:43 PM
  3. Runtime Error '3027': Database or object is read only
    By 4x4Masters in forum Programming
    Replies: 4
    Last Post: 06-08-2010, 08:02 PM
  4. runtime error 2448
    By ds_8805 in forum Forms
    Replies: 3
    Last Post: 04-14-2010, 07:32 PM
  5. Help With Runtime Error 4248
    By KLahvic in forum Programming
    Replies: 1
    Last Post: 04-09-2010, 07:47 AM

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