VBA Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blethyn
    New Member
    • Feb 2007
    • 3

    #1

    VBA Code

    Hi

    I need to be able to have a button on a form that when clicked, it updates a boolean field in the relevant record.

    I bought a book to help me with the recordset code etc but i must be doing something wrong because it doesnt seem to work.

    First it said to create a reference by selecting Microsoft Active X Data Objects 2.7 Library which i did.

    Then it said to create a data source by going to the control panel/administative tools/data sources, which i did.

    Then i tried an example of simply opening a recordset by using the following code:


    Code:
    dim rs as recordset
    
    set rs =CreateObject("ADODB.Recordset")
    
    rs.Open "[tablename]", "[DataSource]"

    I did this and various other things that it suggested but there was always an error at runtime.

    Any suggestions?

    Thanks
    Last edited by NeoPa; Feb 26 '07, 12:38 AM. Reason: Tags for Layout
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Just have a boolean field as a checkbox on the form and you don't have to worry about code at all.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Originally posted by Blethyn
      Hi

      I need to be able to have a button on a form that when clicked, it updates a boolean field in the relevant record.

      I bought a book to help me with the recordset code etc but i must be doing something wrong because it doesnt seem to work.

      First it said to create a reference by selecting Microsoft Active X Data Objects 2.7 Library which i did.

      Then it said to create a data source by going to the control panel/administative tools/data sources, which i did.

      Then i tried an example of simply opening a recordset by using the following code:


      Code:
      dim rs as recordset
      
      set rs =CreateObject("ADODB.Recordset")
      
      rs.Open "[tablename]", "[DataSource]"

      I did this and various other things that it suggested but there was always an error at runtime.

      Any suggestions?

      Thanks
      Your code seems to use concept names instead of actual item names.
      I doubt you actually have a table called [tablename] for instance. Having said that, you really would be well advised to follow Rabbit's advice and do it via a form easily with bound items.
      We can help with that too if required :)

      Comment

      Working...