Saving data in Access table with VB ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bauhaus

    Saving data in Access table with VB ?

    I have a form with a button and if you click the button, a list of invoices
    are generated and saved in the table 'Invoice'.
    Problem is, the data isnt saved :(

    Here's my code:

    Private Sub Knop0_Click()

    Dim Invoicenr As Long
    Dim Invoicedate As Date

    stdocname = "Invoice"
    DoCmd.OpenTable stdocname, acViewNormal, acAd

    Invoicenr = 111111
    Invoicedate = Now

    DoCmd.Save acTable, stdocname

    End Sub

    What am I doing wrong ?


  • kingston via AccessMonster.com

    #2
    Re: Saving data in Access table with VB ?

    I'm going to offer a solution without answering your question:

    Dim strSQL as string

    strSQL = "INSERT INTO Invoice(Invoice nr, Invoicedate) SELECT 111111, '" & Now
    () & "';"
    DoCmd.RunSQL strSQL


    Bauhaus wrote:
    >I have a form with a button and if you click the button, a list of invoices
    >are generated and saved in the table 'Invoice'.
    >Problem is, the data isnt saved :(
    >
    >Here's my code:
    >
    >Private Sub Knop0_Click()
    >
    >Dim Invoicenr As Long
    >Dim Invoicedate As Date
    >
    >stdocname = "Invoice"
    >DoCmd.OpenTabl e stdocname, acViewNormal, acAd
    >
    >Invoicenr = 111111
    >Invoicedate = Now
    >
    >DoCmd.Save acTable, stdocname
    >
    >End Sub
    >
    >What am I doing wrong ?
    --
    Message posted via http://www.accessmonster.com

    Comment

    • Bauhaus

      #3
      Re: Saving data in Access table with VB ?

      Thnx, I'll try it :-)


      Comment

      Working...