Results 1 to 5 of 5

Thread: Databases

  1. #1
    Guest

    Post

    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!

  2. #2
    Member
    Join Date
    Jan 1999
    Location
    London, UK
    Posts
    58

    Post

    Is the control included in your components?

    AndyC

  3. #3
    Guest

    Post

    Don't think it needs to be because I'm not actually using it on a form: just dynamically creating in in a module at runtime...

    I just tried putting in in anyway and it still encounters the same problems.

    Incidentally, the Data Form wizard didn't include it as a component either.

    ------------------
    Matthew Ralston
    E-Mail: [email protected]
    ICQ:31422892
    Web Sites:The Blue Link My Home Page

  4. #4
    New Member
    Join Date
    Nov 1999
    Posts
    8

    Post

    My guess is that you don't have the proper references. Andy Collyer had the right idea. When you add the control to your form, it automatically adds the proper Database references. You can also manually add the references. Click Project, then References in the pull-down menu in VB. I think the one you need is the Microsoft DAO 3.5 Object Library.

    I hope this helps.

    Glenn

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi,Matthew.
    WithEvent is a reserved VB word for creating custom events. From your code it doesn't look that is what you wanted to do. Am I wrong?
    Larisa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width