Any body fancy havin a go at debugging this for me?
It's the code that the Dataform Wizard spewed out, but I'm trying to modify it to run in a module with out loading a seperate form (it's part of a cgi program so I need to keep is as small & memory friendly as poss...)

When I run it, VB doesn't like the the dim withevents... bit, the Set db = New Connection and much more. I've been fiddling with it for ages and I'm getting really fustrated. Help!!
Code:
Private Sub Write_To_Database()
    
    Dim withevents adoPrimaryRS As Recordset
    Dim mbEditFlag As Boolean
    Dim mbAddNewFlag As Boolean
    Dim mbDataChanged As Boolean
    
    
  ' ==Please don't Crash!!!=======
  
  On Error Resume Next
        
  '======== Load Database ==============
    
  Dim db As Connection
  Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=c:\mcg.mdb;"

  Set adoPrimaryRS = New Recordset
  adoPrimaryRS.Open "select Availability,Catagory,Email,Enquiry,Host,[IP Address],Name,News,Telephone,User from Ste", db, adOpenStatic, adLockOptimistic

  '======== Create Text & Check Boxes =====
  Dim txtAvailability As TextBox
  Dim txtCatagory As TextBox
  Dim txtEmail As TextBox
  Dim txtEnquiry As TextBox
  Dim txtHost As TextBox
  Dim txtIPAddress As TextBox
  Dim txtName As TextBox
  Dim txtTelephone As TextBox
  Dim txtUser As TextBox
  Dim chkNews As CheckBox
  
  '=======Bind Text & Checkboxes to Database ========
  
  txtAvailability.DataSource = adoPrimaryRS
  txtCatagory.DataSource = adoPrimaryRS
  txtEmail.DataSource = adoPrimaryRS
  txtEnquiry.DataSource = adoPrimaryRS
  txtHost.DataSource = adoPrimaryRS
  txtIPAddress.DataSource = adoPrimaryRS
  txtName.DataSource = adoPrimaryRS
  txtTelephone.DataSource = adoPrimaryRS
  txtUser.DataSource = adoPrimaryRS
  chkNews.DataSource = adoPrimaryRS
  
  mbDataChanged = False
  
  '=======Update Fields==================
  
  txtAvailability = sContactTime
  txtCatagory = sCatagory
  txtEmail = sEMail
  txtEnquiry = sEnquiry
  txtHost = CGI_RemoteHost
  txtIPAddress = CGI_RemoteAddr
  txtName = sName
  txtTelephone = sTelephone
  txtUser = txtUser
  If UCase$(sNews) = "ON" Then
    chkNews = True
  Else
    chkNews = False
  End If
    
  '=======Update Database==============
  
  adoPrimaryRS.UpdateBatch adAffectAll

  If mbAddNewFlag Then
    adoPrimaryRS.MoveLast              'move to the new record
  End If

  mbEditFlag = False
  mbAddNewFlag = False
  mbDataChanged = False
  
End Sub
I did post this in the Database Q&A section, but I didn't get any replies...so now it's here too!