i *think* i might have narrowed down at least part of the cause of my program behaving so oddly.

this function is supposed to add a customer to both the database and my array "Control.CustomerList.Customer()"

VB Code:
  1. Public Function AddNewToDB(templateCust As clsCustomer, Optional ByVal SaveDatabase As String = "none") As Boolean
  2.  
  3.         ' add new record to the db
  4.         ' open the db
  5.     Dim DB As Database
  6.        
  7.         ' check if a parameter was passed to it
  8.     If SaveDatabase = "none" Then
  9.             ' load default
  10.         Set DB = OpenDatabase(App.Path & "\database.mdb")
  11.     Else
  12.             ' load other
  13.         Set DB = OpenDatabase(SaveDatabase)
  14.         End If
  15.    
  16.     Dim RS As Recordset
  17.     Set RS = DB.OpenRecordset("tunings")
  18.    
  19.     If Not (RS.RecordCount = CustomerList.NumberOfCustomers) Then
  20.         AddNewToDB = False    ' <----------------   HERE
  21.         Exit Function
  22.         End If
  23.    
  24.     RS.MoveLast
  25.     RS.AddNew
  26.    
  27.     Dim myTempCust As clsCustomer
  28.     Set myTempCust = Control.CustomerList.AddCustomer
  29.     Control.CustomerList.DuplicateCust myTempCust.ID, templateCust
  30.     Control.CustomerList.getCustomer(Control.CustomerList.NumberOfCustomers - 1).ID = RS!ID
  31.    
  32.     RS.Edit
  33.         RS!Salutation = templateCust.Salutation
  34.         RS!FirstName = templateCust.FirstName
  35.         RS!MiddleInitials = templateCust.MiddleInitials
  36.         RS!LastName = templateCust.LastName
  37.         RS!CompanyName = templateCust.CompanyName
  38.         RS!Address1 = templateCust.Address1
  39.         RS!Address2 = templateCust.Address2
  40.         RS!Address3 = templateCust.Address3
  41.         RS!Postcode = templateCust.Postcode
  42.         RS!Areacode = templateCust.Areacode
  43.         RS!PhoneNumber = templateCust.PhoneNumber
  44.         RS!Comments = templateCust.Comments
  45.         RS!TuningA = templateCust.TuningA
  46.         RS!TuningB = templateCust.TuningB
  47.         RS!TuningC = templateCust.TuningC
  48.         RS!TuningD = templateCust.TuningD
  49.         RS!TuningsPerYear = templateCust.TuningsPerYear
  50.         RS!TuningDate = templateCust.TuningDate
  51.         RS!Options = templateCust.CodeOptions
  52.         RS!MapX = templateCust.MapX
  53.         RS!MapY = templateCust.MapY
  54.         RS.Update
  55.    
  56.     AddNewToDB = True
  57.    
  58.      ' clean up
  59.     RS.Close
  60.     DB.Close
  61.     Set RS = Nothing
  62.     Set DB = Nothing
  63.  
  64. End Function

but, i have realised that if i start the program afresh, and run this twice by adding 2 customers, the first time it works great, but the second time it breaks at an error trapping point that i marked with [ '<------- Here ]

so i am assuming it either doesnt increment customerlist.size, or the record is not properly added to the database.

now i have just been figuring out this database stuff as i go along, so im hoping that that is where the error is. so could someone have a look over that to spot any errors please!