Results 1 to 2 of 2
  1. #1
    Alphix is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    61

    Not able to input data on same row in table, Need Help.

    Hello I am trying to input data on the same row in my vba script. One set of data is being pulled from the Form and another set is within variables.



    Can someone please help fix my code?



    Click image for larger version. 

Name:	Snap1.jpg 
Views:	6 
Size:	51.0 KB 
ID:	18959

    Code:
    Private Sub Enter_Data_Click()
    Dim sSql As String
    On Error GoTo Enter_Data_Click_Err
        On Error Resume Next
        DoCmd.GoToRecord , "", acNewRec
        
                sSql = "INSERT INTO 04Event_Collector ([EVENT_DATE],[USER],[MACH]) VALUES (#" & Now() & "#, '" & TempVars!pvUserUser & "','" & TempVars!pvMach_Area & "')"
                   Debug.Print sSql
                   
            CurrentDb.Execute sSql, dbFailOnError
        
        If (MacroError <> 0) Then
            Beep
            MsgBox MacroError.Description, vbOKOnly, ""
        End If
    
    Enter_Data_Click_Exit:
        Exit Sub
    Enter_Data_Click_Err:
        MsgBox Error$
        Resume Enter_Data_Click_Exit
    End Sub
    Thank you

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would either use SQL to insert a record or the form, not both (which is why you get 2 records). You can unbind the form and add the other fields to the SQL, or drop the SQL and place those values into textboxes on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2014, 12:07 PM
  2. Replies: 13
    Last Post: 02-26-2012, 08:28 AM
  3. Command button to input data in a table
    By wilsgaard in forum Forms
    Replies: 1
    Last Post: 08-07-2011, 07:59 PM
  4. Replies: 4
    Last Post: 07-17-2011, 06:07 PM
  5. Replies: 3
    Last Post: 07-13-2011, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums