Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2003
    Location
    India
    Posts
    6

    Question Unanswered: How can a new record be added to an existing table using the code editor in MS Access

    Dear friends,
    I m using MS Access code editor to add new records in an already existing access table but am not able to do so. Can you help me out ?

  2. #2
    Join Date
    May 2003
    Posts
    47

    code new record

    Could you explain with a little more detail ? Are you simply opening a form and want to start with a new record ? Or are you trying to place data in the table directly from code with no user input ? Please give us some more detail .

  3. #3
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How can a new record be added to an existing table using the code editor in MS Access

    Originally posted by samba
    Dear friends,
    I m using MS Access code editor to add new records in an already existing access table but am not able to do so. Can you help me out ?
    DoCmd.GoToRecord , , acNewRec

  4. #4
    Join Date
    May 2003
    Posts
    47

    Re: How can a new record be added to an existing table using the code editor in MS Access

    Originally posted by VBAPROGRAMMER
    DoCmd.GoToRecord , , acNewRec
    Yes , he PM'ed me and I gave hime the same thing but apparently he is doing all of this totally in VB 6.0 and is looking for the syntax for VB 6 , which I am not familiar with .

  5. #5
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How can a new record be added to an existing table using the code editor in MS Access

    Originally posted by samba
    Dear friends,
    I m using MS Access code editor to add new records in an already existing access table but am not able to do so. Can you help me out ?
    for adding record in vb 6.0
    http://msdn.microsoft.com/library/de...oltosource.asp

  6. #6
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How can a new record be added to an existing table using the code editor in MS Access

    [QUOTE][SIZE=1]Originally posted by samba

    This solution is from ur previous Question.
    The Problem i suspected in that ur just UPDATING the last REcord in this table but ur not adding New record into it.You should use rs.AddNew instead of rs.MoveLast
    So your code shoud look like this
    ConnectRecord 'method to connect to the database
    rs.AddNew

    txtNew.SetFocus
    'MsgBox rs(1).Value
    'rs(1) = txtNew.Text


    txtSecName.SetFocus 'text box to accept name
    rs(2) = txtSecName.Text


    txtSecSym.SetFocus 'text box to accept symbol
    rs(3) = txtSecSym.Text


    txtSecType.SetFocus 'text box to accept type
    rs(4) = txtSecType.Text


    txtShOwn.SetFocus 'text box to accept ownership
    rs(5) = txtShOwn.Text
    rs.Update

  7. #7
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How can a new record be added to an existing table using the code editor in MS Access

    [QUOTE][SIZE=1]Originally posted by samba
    instead of using rs(1)=txtnew.text
    user
    rs![ColumnName]= txtNew.Text

  8. #8
    Join Date
    Jun 2003
    Location
    India
    Posts
    6

    Re: How can a new record be added to an existing table using the code editor in MS Access

    Originally posted by VBAPROGRAMMER
    DoCmd.GoToRecord , , acNewRec
    Dear VBAPROGRAMMER,
    Let me be frank that I am not having too much exposure to Access so I was trying to do the same through Access VB Code editor.

    Further MS Access allows you to add a button & automatically asks what event to attached with the same.Thus the code snippet you & ghost1157 provided was already available to me but clicking the button yields no results. What could be problem ? This is my first encounter with access coding.

    Access has provided me this code.....

    Private Sub Command26_Click()
    On Error GoTo Err_Command26_Click

    DoCmd.GoToRecord , , acNewRec 'HOW SHOULD THE VALUES OF

    THE TEXT BOXES BE TRAPPED & SENT TO THE TABLE

    Exit_Command26_Click:
    Exit Sub

    Err_Command26_Click:
    MsgBox Err.Description
    Resume Exit_Command26_Click

    End Sub

Posting Permissions

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