Converting Access 2.0 Database to Access 2013 - Need VBA help

kcply

New member
Local time
Today, 14:00
Joined
Mar 25, 2015
Messages
3
Hi,

I'm currently tasked with converting a Access 2.0 Database to Access 2013 and have run into a wall with the form code. It was written in Access 2.0 and I keep getting errors when navigating through the forms. I have pasted a snippet of code from one of the buttons that is causing the issue. Whenever I click the button associated with the issue(there are several buttons with similar problems), it pops up an error saying: "Compile error: Method or data member not found". It then high lights the .[Cup] section of code in the If Response =6 Then subblock. Can someone please help me?

Code:
Private Sub Button41_Click()
On Error GoTo Err_Button41_Click
DoCmd.Hourglass True

    
Dim MyDB As Database, MYRECORDS As Recordset, Xcounter As Integer
Dim SELECTEDPROCESS As String

SELECTEDPROCESS = "'" & Forms![PROCESS INFORMATION]![SELEWWFPROCESS].Form![PROCESS] & "'"
Xcounter = 0
selectedproject = [LLPROJECT]
Set MyDB = DBEngine.Workspaces(0).Databases(0)

MYRECORDScrit = "SELECT SELEPROC.LLPROJECT, SELEPROC.PROCESS, SELEPROC.POLLNAME, SELEPROC.FORMULA_FORMAT, SELEPROC.Cup, SELEPROC.Reference FROM SELEPROC WHERE ((SELEPROC.LLPROJECT = " & [LLPROJECT] & ") AND (SELEPROC.PROCESS = " & SELECTEDPROCESS & "))"
'MsgBox MYRECORDScrit
Set MYRECORDS = MyDB.OpenRecordset(MYRECORDScrit, DB_OPEN_DYNASET)
If MYRECORDS.BOF Then
    MsgBox "No pollutants records to check.  Press enter or click to return to form.", , "LLIDS - Intelligence in action!"
    DoCmd.Hourglass False
    'Exit Sub
Else
    MYRECORDS.MoveFirst
    MYRECORDS.MoveLast
End If
'searchcrit = "Cup = 0"
searchcrit = "((Cup = 0) OR (ISNULL(Cup)))"

MYRECORDS.FindFirst searchcrit
If MYRECORDS.NoMatch Then
    'DO NOTHING
Else
    Response = MsgBox("There are " + Trim(Str(MYRECORDS.RecordCount)) + " records.  Delete any pollutants with Cup = 0 before closing screen?", 4, "LLIDS - Intelligence in action!")
    'RESPONSE=6 MEANS YES

    If Response = 6 Then
        MYRECORDS.MoveFirst
        Do Until MYRECORDS.EOF
            If ((MYRECORDS[B].[Cup][/B] = 0) Or (IsNull(MYRECORDS.[Cup]))) Then
                MYRECORDS.Delete
            End If
            MYRECORDS.MoveNext
       Loop
    Else
        Response = MsgBox("No records checked or deleted.  Please note that entries without a defined Cup value should be deleted.  Return to form?", 4, "LLIDS - Intelligence in action!")
        If Response = 6 Then
            DoCmd.Hourglass False
            Exit Sub
        End If
    End If
End If

   
PROJECTNUMBER = [LLPROJECT]
DoCmd.Hourglass False
DoCmd.Close
Forms![LLIDS Main Menu].Visible = True

Exit_Button41_Click:
    Exit Sub

Err_Button41_Click:
    MsgBox Error$
    Resume Exit_Button41_Click
    
End Sub
 
Last edited:
AFAIK recommended procedure for converting archaic access versions is to A2003 and then from there onwards. Try that, if you have access to an A2003 installation.


Note the edits below:


Offhand, newer A versions prefer or even demand disambiguation, eg. not Database but DAO.Database, not Recordset but DAO.recordset and so on,

When you submit code, use code brackets or join other offenders in the doghouse. (codebrackets: Go Advanced, select code, click #)
 
Last edited:
Thanks for your reply. I have already got all of the tables, queries, forms, modules, reports and macros imported into an Access 2013 .accdb file. I had to incrementally convert the database starting with Access 2000 then Access 2003 then Access 2007. Now, I can open it in Access 2013 and navigate through the forms until I hit procedures that use code similar to the code i pasted above. I have a feeling it has to do with the recordset code but am not sure how to proceed.
 
In your code, try use ! instead of . for fields within recordsets.
eg. (MYRECORDS![Cup]
Dim MyDB As DAO.Database, MYRECORDS As DAO.Recordset, Xcounter As Integer
 
jdraw,

Thank you so much for your input. I applied your suggestion across the database and it worked wonderfully. I appreciate you sharing your insight.
 

Users who are viewing this thread

Back
Top Bottom