Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add record to table from command button (2000)

    Hi looking to add a record to a table from a command button on a form. What I would take is to ID fields and put the into a table along with the current date and then requery a sub form on the form which I know how to do but it's building the vb to enable it to enter the info in the table so it's transparent to the user [img]/forums/images/smilies/smile.gif[/img]

    Thanks in advance for your help.
    Best Regards,

    Luke

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add record to table from command button (2000)

    You can use DAO or ADO to add a record to a table. Here is an ADO example using the Products table from the Northwind database:

    Dim cnn As ADODB.Connection
    Dim rst As New ADODB.Recordset

    Set cnn = CurrentProject.Connection
    rst.Open "tblProducts", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
    rst.AddNew
    rst!strProductName = "Sugar"
    rst!fkeyCategoryID = 3
    rst.Update
    rst.Close

    Set rst = Nothing
    Set cnn = Nothing

Posting Permissions

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