Results 1 to 15 of 15
  1. #1
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9

    Converting Access 95 DB to 2010 Issues

    Hello,

    I'm here for some help in converting or solving the errors in an old Access DB used with Office 95. The database and forms appear to have converted okay. In the sense that they are all there and visible. But once you try adding new records via the forms, errors begin to be generated. Unfortunately, it looks like I should have either paid more attention back in Uni or used the lessons more over the years as it would help me with solving whats probably a fairly easy problem.

    Typing something in to the form and then clicking to go to the next form reveals this error:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 11.57.27.png 
Views:	19 
Size:	149.4 KB 
ID:	21439

    When opening debug I see this:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 11.57.35.png 
Views:	19 
Size:	80.5 KB 
ID:	21440

    Something tells me that its a pretty easy fix. Please can someone help?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would not expect to see that error. For instance
    For i = 1 to total

    It seems you are dealing with Variants and it would be difficult to get an overflow with a variant. The only thing I can guess is that something is causing you code to jump into your iteration statement at the
    bypass:

    I would probably look into changing the macro that is called to VBA and understanding why there is the bypass: line. Maybe you can search for "GoTo bypass".

  3. #3
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Thanks so much for the reply. I'm a complete noob with this really and wouldn't quite know what to change things too. I have found the line you referenced.


    The code in the VBA looks like this:

    Option Compare Database
    Option Explicit


    Private Sub butt1_Click()
    DoCmd.GoToRecord , , acFirst
    End Sub


    Private Sub butt2_Click()
    DoCmd.GoToRecord , , acPrevious
    End Sub




    Private Sub butt3_Click()
    DoCmd.GoToRecord , , acNext
    End Sub




    Private Sub butt4_Click()


    DoCmd.GoToRecord , , acLast


    End Sub




    Private Sub butt6_Click()
    DoCmd.GoToRecord , , acNewRec
    End Sub




    Private Sub Cat_No___UK__Exit(Cancel As Integer)
    Dim db As DATABASE
    Dim recs As Recordset
    Dim ctltext As Control
    Dim total As Long, current As Long
    Dim testuk As String, testint As String, temp As String
    Dim i As Integer

    Set db = CurrentDb
    Set recs = db.OpenRecordset("main")

    current = Forms!main.CurrentRecord
    Set ctltext = Forms!main![Cat No (UK)]
    ctltext = SetFocus
    testuk = ctltext
    Debug.Print testuk
    Stop

    If recs(3) = Null Then
    GoTo fin
    End If

    recs.MoveLast
    total = recs.RecordCount
    recs.MoveFirst

    For i = 1 To total
    temp = LCase(recs(3))
    Debug.Print testuk, temp
    Stop
    If testuk = temp Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    Next i
    If testint = "y" Then
    If MsgBox("Duplicate Cat No!! ", vbOKCancel) = vbOK Then
    With recs
    .AddNew
    recs(3) = ""
    .UPDATE
    End With
    End If
    End If
    fin:
    End Sub


    Private Sub catuk_Exit(Cancel As Integer)


    End Sub


    Private Sub Cat_No__INT__Exit(Cancel As Integer)
    Dim db As DATABASE
    Dim recs As Recordset
    Dim ctltext As Control
    Dim testuk As Variant, testint As Variant, temp As Variant
    Dim current As Long, total As Long
    Dim mess As String
    Dim i As Integer


    DoCmd.RunMacro "saverec"

    Set recs = Me.RecordsetClone()

    recs.MoveLast
    testuk = recs(4)
    If IsNull(testuk) Or (testuk = "") Then
    GoTo fin
    End If
    total = recs.RecordCount
    total = total - 1
    recs.MoveFirst
    For i = 1 To total
    temp = recs(4)
    'Debug.Print testuk, temp
    'Stop
    If IsNull(testuk) Then
    GoTo bypass
    End If
    If LCase(testuk) = LCase(temp) Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    bypass:
    Next i
    If testint = "y" Then
    mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
    If MsgBox(mess, vbOKOnly) = vbOK Then
    recs.MoveLast
    With recs
    .Edit
    recs(4) = Null
    .UPDATE
    End With
    End If
    'Set ctltext = Forms!main![Cat No (INT)]
    'ctltext.SetFocus

    End If

    recs.Close
    fin:
    End Sub


    Private Sub Cat_No__UK__Exit(Cancel As Integer)
    Dim db As DATABASE
    Dim recs As Recordset
    Dim ctltext As Control
    Dim testuk As Variant, testint As Variant, temp As Variant
    Dim current As Long, total As Long
    Dim mess As String
    Dim i As Integer


    DoCmd.RunMacro "saverec"

    Set recs = Me.RecordsetClone()

    recs.MoveLast
    testuk = recs(3)
    If IsNull(testuk) Or (testuk = "") Then
    GoTo fin
    End If
    total = recs.RecordCount
    total = total - 1
    recs.MoveFirst
    For i = 1 To total
    temp = recs(3)
    'Debug.Print testuk, temp
    'Stop
    If IsNull(testuk) Then
    GoTo bypass
    End If
    If LCase(testuk) = LCase(temp) Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    bypass:
    Next i
    If testint = "y" Then
    mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
    If MsgBox(mess, vbOKOnly) = vbOK Then
    recs.MoveLast
    With recs
    .Edit
    recs(3) = Null
    .UPDATE
    End With
    End If
    'Set ctltext = Forms!main![Cat No (UK)]
    'ctltext.SetFocus

    End If

    recs.Close
    fin:
    End Sub




    Private Sub Distributor_ID_NotInList(NewData As String, Response As Integer)

    Dim db As DATABASE
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Distributor")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    !Distributor = temp
    .UPDATE
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub


    Private Sub Form_Current()
    Dim db As DATABASE
    Dim current, total As Long

    Dim ctltext As Control
    Dim recclone As Recordset
    Dim intnewrecord As Integer

    Set recclone = Me.RecordsetClone()

    'recclone.MoveNext
    current = Forms!main.CurrentRecord
    Set ctltext = Forms!main!Text88


    recclone.MoveLast
    total = recclone.RecordCount
    Set ctltext = Forms!main!Text90











    intnewrecord = IsNull(Me.[Stock No])


    If intnewrecord Then
    butt1.Enabled = True
    butt3.Enabled = False
    butt2.Enabled = True
    butt4.Enabled = True
    butt6.Enabled = False
    Exit Sub
    End If


    butt6.Enabled = True


    If recclone.RecordCount = 0 Then
    butt1.Enabled = False
    butt3.Enabled = False
    butt2.Enabled = False
    butt4.Enabled = False
    Else


    recclone.Bookmark = Me.Bookmark
    recclone.MovePrevious
    butt1.Enabled = Not (recclone.BOF)
    butt2.Enabled = Not (recclone.BOF)
    recclone.MoveNext

    recclone.MoveNext
    butt4.Enabled = Not (recclone.EOF)
    butt3.Enabled = Not (recclone.EOF)
    recclone.MovePrevious
    End If


    recclone.Close


    End Sub


    Sub Command79_Click()
    On Error GoTo Err_Command79_Click




    DoCmd.Close


    Exit_Command79_Click:
    Exit Sub


    Err_Command79_Click:
    MsgBox Err.Description
    Resume Exit_Command79_Click

    End Sub
    Sub Command80_Click()
    On Error GoTo Err_Command80_Click




    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70


    Exit_Command80_Click:
    Exit Sub


    Err_Command80_Click:
    MsgBox Err.Description
    Resume Exit_Command80_Click

    End Sub


    Private Sub Music_sub_type_ID_NotInList(NewData As String, Response As Integer)
    Dim db As DATABASE
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Music Sub-type")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    ![Music Sub-type] = temp
    .UPDATE
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub


    Private Sub Music_type_ID_NotInList(NewData As String, Response As Integer)
    Dim db As DATABASE
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Music Type")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    ![Music Type] = temp
    .UPDATE
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub




    Sub Text88_BeforeUpdate(Cancel As Integer)


    End Sub




    Sub printrec_Click()
    On Error GoTo Err_printrec_Click


    Dim db As DATABASE
    Dim recs As Recordset
    Dim current As Long


    Set db = CurrentDb
    Set recs = db.OpenRecordset("main")

    With recs

    End With





    Exit_printrec_Click:
    Exit Sub


    Err_printrec_Click:
    MsgBox Err.Description
    Resume Exit_printrec_Click

    End Sub
    Sub printer1_Click()
    On Error GoTo Err_printer1_Click




    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.PrintOut acSelection


    Exit_printer1_Click:
    Exit Sub


    Err_printer1_Click:
    MsgBox Err.Description
    Resume Exit_printer1_Click

    End Sub
    Sub printer2_Click()
    On Error GoTo Err_printer2_Click


    Dim stDocName As String


    stDocName = "label"
    DoCmd.OpenReport stDocName, acNormal


    Exit_printer2_Click:
    Exit Sub


    Err_printer2_Click:
    MsgBox Err.Description
    Resume Exit_printer2_Click

    End Sub

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    OK, I see the GoTo line. It was there the whole time but I did not see it. I am not sure why you are getting the error. Make a copy of your DB/Form and replace the code between
    Code:
    Private Sub Cat_No__UK__Exit(Cancel As Integer)
    and the VERY NEXT end sub line
    Code:
    End Sub
    ... with the following code. I placed a msgbox in there that should give you the value of "total" before any errors. Maybe we can learn something from the message box. I also made a couple of other minor changes. Perhaps the loop was falling because of an empty string within the field or there was only one record within the recordset. I added some code to check for empty string and I also changed the number of times the loop would iterate.

    Code:
    ' Dim db As Database
    Dim db As DAO.Database
     Dim recs As Recordset
     Dim ctltext As Control
     Dim testuk As Variant, testint As Variant, temp As Variant
     Dim current As Long, total As Long
     Dim mess As String
     Dim i As Integer
    
     DoCmd.RunMacro "saverec"
    'Set recs = Me.RecordsetClone()
    Set recs = Me.RecordsetClone
    'Code added
    If recs.RecordCount < 1 Then
    MsgBox "No Records were found.", vbCritical, "Exiting Now"
    GoTo fin
    End If
    'end code added
    recs.MoveLast
     
     testuk = recs(3)
     If IsNull(testuk) Or (testuk = "") Then
     GoTo fin
     End If
     total = recs.RecordCount
     'temp message box to see what the total is
     MsgBox "total = " & total
     'end  'temp message box to see what the total is
    '' I don't understand why subtract one here
    ''if you are starting index at 1 and not 0
    ''so I commented this out
    ' total = total - 1
     
     
     recs.MoveFirst
     For i = 1 To total
     temp = recs(3)
     'Debug.Print testuk, temp
     'Stop
     'I added check for empty string ""
     If IsNull(testuk) Or (testuk = "") Then
     GoTo bypass
     End If
     If LCase(testuk) = LCase(temp) Then
     testint = "y"
     Exit For
     End If
     recs.MoveNext
    bypass:
     Next i
     
     If testint = "y" Then
     mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
     If MsgBox(mess, vbOKOnly) = vbOK Then
     recs.MoveLast
     With recs
     .Edit
     recs(3) = Null
     .Update
     End With
     End If
     'Set ctltext = Forms!main![Cat No (UK)]
     'ctltext.SetFocus
     End If
     recs.Close
    fin:

  5. #5
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Thanks so much for doing this. I've added the code at the points specified and got this coming up now:

    Clicking the next box:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 14.53.22.png 
Views:	17 
Size:	162.2 KB 
ID:	21441

    Followed by:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 14.53.32.png 
Views:	17 
Size:	147.1 KB 
ID:	21442

    which leads to this event here:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 14.53.43.png 
Views:	17 
Size:	61.6 KB 
ID:	21443

    I've uploaded the database to my BOX Account.

    https://app.box.com/s/fvbcbyur2dv2t8cj1q8sy9eehw9qqo78

    I'm asking a huge amount but the files can be downloaded from there. I have been using the X_Records V001 NEW.accdb. A copy of the Access 95 format DB is also there too. If its a no hope case then please gladly just state that. Thanks for your work and help on this so far.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Hmmm, maybe because you initialize i to equal 1 its Variant type is set to a smaller data type. Try being explicit with your i declaration. Try this code here instaead. I changed i to lngCount and declared it as long.


    Code:
     ' Dim db As Database
     Dim db As DAO.Database
      Dim recs As Recordset
      Dim ctltext As Control
      Dim testuk As Variant, testint As Variant, temp As Variant
      Dim current As Long, total As Long
      Dim mess As String
      Dim i As Integer
    
      DoCmd.RunMacro "saverec"
     'Set recs = Me.RecordsetClone()
    Set recs = Me.RecordsetClone
     'Code added
     If recs.RecordCount < 1 Then
     MsgBox "No Records were found.", vbCritical, "Exiting Now"
     GoTo fin
     End If
     'end code added
     recs.MoveLast
      
      testuk = recs(3)
      If IsNull(testuk) Or (testuk = "") Then
      GoTo fin
      End If
    
     Dim lngCount As Long
      total = recs.RecordCount
      'temp message box to see what the total is
      MsgBox "total = " & total
      'end  'temp message box to see what the total is
     '' I don't understand why subtract one here
     ''if you are starting index at 1 and not 0
     ''so I commented this out
     ' total = total - 1
      
      
      recs.MoveFirst
    ' For i = 1 To total
     For lngCount = 1 To total
      temp = recs(3)
      'Debug.Print testuk, temp
      'Stop
      'I added check for empty string ""
      If IsNull(testuk) Or (testuk = "") Then
      GoTo bypass
      End If
      If LCase(testuk) = LCase(temp) Then
      testint = "y"
      Exit For
      End If
      recs.MoveNext
     bypass:
     Next lngCount
     ' Next i
      
      If testint = "y" Then
      mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
      If MsgBox(mess, vbOKOnly) = vbOK Then
      recs.MoveLast
      With recs
      .Edit
      recs(3) = Null
     .Update
      End With
      End If
      'Set ctltext = Forms!main![Cat No (UK)]
      'ctltext.SetFocus
      End If
      recs.Close
     fin:

  7. #7
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Thanks once again. Really making progress here I reckon. So once i've input the first Catalogue number I get this:

    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 17.39.38.png 
Views:	15 
Size:	161.8 KB 
ID:	21445

    Followed by this and then the data in the box disappears after pressing okay:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 17.39.48.png 
Views:	14 
Size:	160.9 KB 
ID:	21446

    Which ends:
    Click image for larger version. 

Name:	Screen Shot 2015-07-29 at 17.42.12.png 
Views:	14 
Size:	164.2 KB 
ID:	21447

    Last steps I think. Thank you so much for this.

  8. #8
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Thinking on the first total it shows there is the amount of records in the Database. Is it trying to add these new records as 0 each time? I've noticed that the Record box at the bottom does not show the number of records in the Database.

  9. #9
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Here's all the VBA code:

    Option Compare DatabaseOption Explicit


    Private Sub butt1_Click()
    DoCmd.GoToRecord , , acFirst
    End Sub


    Private Sub butt2_Click()
    DoCmd.GoToRecord , , acPrevious
    End Sub




    Private Sub butt3_Click()
    DoCmd.GoToRecord , , acNext
    End Sub




    Private Sub butt4_Click()


    DoCmd.GoToRecord , , acLast


    End Sub




    Private Sub butt6_Click()
    DoCmd.GoToRecord , , acNewRec
    End Sub




    Private Sub Cat_No___UK__Exit(Cancel As Integer)
    Dim db As Database
    Dim recs As Recordset
    Dim ctltext As Control
    Dim total As Long, current As Long
    Dim testuk As String, testint As String, temp As String
    Dim i As Integer

    Set db = CurrentDb
    Set recs = db.OpenRecordset("main")

    current = Forms!main.CurrentRecord
    Set ctltext = Forms!main![Cat No (UK)]
    ctltext = SetFocus
    testuk = ctltext
    Debug.Print testuk
    Stop

    If recs(3) = Null Then
    GoTo fin
    End If

    recs.MoveLast
    total = recs.RecordCount
    recs.MoveFirst

    For i = 1 To total
    temp = LCase(recs(3))
    Debug.Print testuk, temp
    Stop
    If testuk = temp Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    Next i
    If testint = "y" Then
    If MsgBox("Duplicate Cat No!! ", vbOKCancel) = vbOK Then
    With recs
    .AddNew
    recs(3) = ""
    .Update
    End With
    End If
    End If
    fin:
    End Sub


    Private Sub catuk_Exit(Cancel As Integer)


    End Sub


    Private Sub Cat_No__INT__Exit(Cancel As Integer)
    Dim db As Database
    Dim recs As Recordset
    Dim ctltext As Control
    Dim testuk As Variant, testint As Variant, temp As Variant
    Dim current As Long, total As Long
    Dim mess As String
    Dim i As Integer


    DoCmd.RunMacro "saverec"

    Set recs = Me.RecordsetClone()

    recs.MoveLast
    testuk = recs(4)
    If IsNull(testuk) Or (testuk = "") Then
    GoTo fin
    End If
    total = recs.RecordCount
    total = total - 1
    recs.MoveFirst
    For i = 1 To total
    temp = recs(4)
    'Debug.Print testuk, temp
    'Stop
    If IsNull(testuk) Then
    GoTo bypass
    End If
    If LCase(testuk) = LCase(temp) Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    bypass:
    Next i
    If testint = "y" Then
    mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
    If MsgBox(mess, vbOKOnly) = vbOK Then
    recs.MoveLast
    With recs
    .Edit
    recs(4) = Null
    .Update
    End With
    End If
    'Set ctltext = Forms!main![Cat No (INT)]
    'ctltext.SetFocus

    End If

    recs.Close
    fin:
    End Sub


    Private Sub Cat_No__UK__Exit(Cancel As Integer)
    ' Dim db As Database
    Dim db As DAO.Database
    Dim recs As Recordset
    Dim ctltext As Control
    Dim testuk As Variant, testint As Variant, temp As Variant
    Dim current As Long, total As Long
    Dim mess As String
    Dim i As Integer


    DoCmd.RunMacro "saverec"
    'Set recs = Me.RecordsetClone()
    Set recs = Me.RecordsetClone
    'Code added
    If recs.RecordCount < 1 Then
    MsgBox "No Records were found.", vbCritical, "Exiting Now"
    GoTo fin
    End If
    'end code added
    recs.MoveLast

    testuk = recs(3)
    If IsNull(testuk) Or (testuk = "") Then
    GoTo fin
    End If


    Dim lngCount As Long
    total = recs.RecordCount
    'temp message box to see what the total is
    MsgBox "total = " & total
    'end 'temp message box to see what the total is
    '' I don't understand why subtract one here
    ''if you are starting index at 1 and not 0
    ''so I commented this out
    ' total = total - 1


    recs.MoveFirst
    ' For i = 1 To total
    For lngCount = 1 To total
    temp = recs(3)
    'Debug.Print testuk, temp
    'Stop
    'I added check for empty string ""
    If IsNull(testuk) Or (testuk = "") Then
    GoTo bypass
    End If
    If LCase(testuk) = LCase(temp) Then
    testint = "y"
    Exit For
    End If
    recs.MoveNext
    bypass:
    Next lngCount
    ' Next i

    If testint = "y" Then
    mess = "This is a duplicate Cat No" + Chr(13) + Chr(10) + "Duplicate Record " + Str(i)
    If MsgBox(mess, vbOKOnly) = vbOK Then
    recs.MoveLast
    With recs
    .Edit
    recs(3) = Null
    .Update
    End With
    End If
    'Set ctltext = Forms!main![Cat No (UK)]
    'ctltext.SetFocus
    End If
    recs.Close
    fin:
    End Sub




    Private Sub Distributor_ID_NotInList(NewData As String, Response As Integer)

    Dim db As Database
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Distributor")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    !Distributor = temp
    .Update
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub


    Private Sub Form_Current()
    Dim db As Database
    Dim current, total As Long

    Dim ctltext As Control
    Dim recclone As Recordset
    Dim intnewrecord As Integer

    Set recclone = Me.RecordsetClone()

    'recclone.MoveNext
    current = Forms!main.CurrentRecord
    Set ctltext = Forms!main!Text88


    recclone.MoveLast
    total = recclone.RecordCount
    Set ctltext = Forms!main!Text90











    intnewrecord = IsNull(Me.[Stock No])


    If intnewrecord Then
    butt1.Enabled = True
    butt3.Enabled = False
    butt2.Enabled = True
    butt4.Enabled = True
    butt6.Enabled = False
    Exit Sub
    End If


    butt6.Enabled = True


    If recclone.RecordCount = 0 Then
    butt1.Enabled = False
    butt3.Enabled = False
    butt2.Enabled = False
    butt4.Enabled = False
    Else


    recclone.Bookmark = Me.Bookmark
    recclone.MovePrevious
    butt1.Enabled = Not (recclone.BOF)
    butt2.Enabled = Not (recclone.BOF)
    recclone.MoveNext

    recclone.MoveNext
    butt4.Enabled = Not (recclone.EOF)
    butt3.Enabled = Not (recclone.EOF)
    recclone.MovePrevious
    End If


    recclone.Close


    End Sub


    Sub Command79_Click()
    On Error GoTo Err_Command79_Click




    DoCmd.Close


    Exit_Command79_Click:
    Exit Sub


    Err_Command79_Click:
    MsgBox Err.Description
    Resume Exit_Command79_Click

    End Sub
    Sub Command80_Click()
    On Error GoTo Err_Command80_Click




    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70


    Exit_Command80_Click:
    Exit Sub


    Err_Command80_Click:
    MsgBox Err.Description
    Resume Exit_Command80_Click

    End Sub


    Private Sub Music_sub_type_ID_NotInList(NewData As String, Response As Integer)
    Dim db As Database
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Music Sub-type")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    ![Music Sub-type] = temp
    .Update
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub


    Private Sub Music_type_ID_NotInList(NewData As String, Response As Integer)
    Dim db As Database
    Dim Ctl As Control
    Dim fld As Field
    Dim tbl As TableDef
    Dim recs As Recordset
    Dim temp As String

    temp = NewData

    Set db = CurrentDb
    Set recs = db.OpenRecordset("Music Type")

    If MsgBox("Data not in list...Add it? ", vbOKCancel) = vbOK Then
    Response = acDataErrAdded
    With recs
    .AddNew
    ![Music Type] = temp
    .Update
    End With
    Else
    Response = acDataErrContinue
    End If

    End Sub




    Sub Text88_BeforeUpdate(Cancel As Integer)


    End Sub




    Sub printrec_Click()
    On Error GoTo Err_printrec_Click


    Dim db As Database
    Dim recs As Recordset
    Dim current As Long


    Set db = CurrentDb
    Set recs = db.OpenRecordset("main")

    With recs

    End With





    Exit_printrec_Click:
    Exit Sub


    Err_printrec_Click:
    MsgBox Err.Description
    Resume Exit_printrec_Click

    End Sub
    Sub printer1_Click()
    On Error GoTo Err_printer1_Click




    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.PrintOut acSelection


    Exit_printer1_Click:
    Exit Sub


    Err_printer1_Click:
    MsgBox Err.Description
    Resume Exit_printer1_Click

    End Sub
    Sub printer2_Click()
    On Error GoTo Err_printer2_Click


    Dim stDocName As String


    stDocName = "label"
    DoCmd.OpenReport stDocName, acNormal


    Exit_printer2_Click:
    Exit Sub


    Err_printer2_Click:
    MsgBox Err.Description
    Resume Exit_printer2_Click

    End Sub


  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    When you post code here in the forum, you can maintain formatting by using the button with the # symbol. This will provide Code tags you can place your code between.

    Why don't you try this. Upload a copy of your DB here. Instead of uploading the entire DB, just include the forms and modules. Create a new Access file and with your new file open, use the Import Wizard to import the Forms and Modules from your Original Copy. You can find the Import Wizard under the External Data tab of the Ribbon.


    After you import the objects to your new file, compact and repair, zip the file, and upload it here.

    I should have a chance later to take a look at it. I can't make any promises to fix everything but I will take a look.

  11. #11
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Thanks for your help with this. The Database is attached. But it does error quite a bit with out the rest of the data. You can get the full thing from my Box account. Its literally 16mb!

    Forms, Macros.accdb.zip

    Box Shared Folder
    https://app.box.com/s/fvbcbyur2dv2t8cj1q8sy9eehw9qqo78

  12. #12
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    BUMP!

    Still looking for some help with this. I'm sure its close to being resolved

  13. #13
    ChrisE is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    9
    Here's the Forms, Macros uploaded.

    Exported FORMS.zip

  14. #14
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sorry I missed your post back in July. I, just now, took at look at that DB you uploaded in July. The code I provided previously took care of a couple of issues with the original DB file. The original DB file was using something called implicit declaration. This was causing an issue when dealing with record counts greater than 32,000. Aside from that, there are other problems, too.

    Basically, 80% of your Macros are not working. They are not working because the tables are missing, they did not convert over to the new version of Access, or they were not created correctly.

    My vote is that the Macros did not convert over to the newer version of Access. There is one command button on form Main that will not work because of the Macro issue. Also, there are several command buttons in the xrecords form that will not work because of the command button issue.

    Most all of your application does not work. It would be easiest to rebuild the entire thing, keeping in mind what it is that you would like the application to do. In other words, there is not much I can see there that is worth salvaging, if anything at all.

  15. #15
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    From what I read, converting Access 95 DB to 2010, the recommended method is to first convert to A2000 (A2002/A2003), get the dB working properly, then convert to A2007/2010. In each conversion there will probably be issues - some minor, some major.

    Moving from A95 to A2010 will have major issues, as you have seen. Macros tend not to work because of depreciated commands; "DoMenuCommand" is one of the depreciated commands.

    Then there are naming issues, logic bombs, errors in declarations and use of reserved words as object names.

    - The naming issues include spaces, punctuation and special characters in object names.
    Examples: "Cat No (UK)" , "Music sub-type ID" and "12" picture".
    Should only use letters, numbers and possible the underscore in object names.


    - Use of reserved words as object names:
    macros named" "Print", "Delete", "Printer"
    Field names: "Date", "Single", "Double"


    - Example of "Errors in declarations"
    Code:
        Dim current As Long, total As Long
        Dim mess As String
        Dim i As Integer
    
        For i = 1 To total
    
        Next i
    Here, "total" is declared as a Long (-2,147,483,648 to 2,147,483,647), but "i" is declared as an Integer (-32,768 to 32767). So once "i" exceeds 32767, you get an error.


    - "Private Sub butt1_Click()" - "butt1" is a poor name..."btnMoveFirst" would be a better name (IMO) since it is more descriptive.

    - There are lots of "GoTo" commands. This is poor programming and leads to spaghetti code (a problem with IBM BASIC, GW-BASIC, et al). The only time there should be a "GoTo" command is the error handler.


    - I also would convert all of the macros to VBA code. I never use macros.



    The good news is that all of these issues can be resolved, but it would take time.

    (My $0.02....)

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

Similar Threads

  1. Replies: 2
    Last Post: 03-16-2015, 04:09 AM
  2. Replies: 2
    Last Post: 02-11-2014, 09:41 AM
  3. Replies: 3
    Last Post: 08-12-2013, 10:12 AM
  4. Replies: 7
    Last Post: 05-13-2013, 11:37 AM
  5. Converting matrix to column in access 2010
    By peteramullen in forum Access
    Replies: 4
    Last Post: 08-13-2012, 05:58 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