Results 1 to 4 of 4
  1. #1
    TG_W is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299

    Event Stopping - need help please

    I have a VBA code that is initiated when I hit the Process button on my form. It is supposed to update 4 fields and previously worked. I haven't revisited the form or the table that is supposed to be updated in a few weeks, and now it doesn't seem to want to work. The entire code is below, and the debugger jumps to "dbs.Execute strSQL, dbFailOnError".



    Thank you in advance for your help.



    Private Sub Process_Click()
    Dim X
    If IsNull(Me!Sender) Then ErrMsg: Exit Sub
    If IsNull(Me!Recipient) Then ErrMsg: Exit Sub
    If IsNull(Me!SeqNo) Then ErrMsg: Exit Sub
    If IsNull(Me!IssueDate) Then ErrMsg: Exit Sub
    Dim dbs As Database
    Set dbs = CurrentDb

    strSQL = "INSERT INTO TransNo "
    strSQL = strSQL & " (Sender,Recipient,SeqNo,IssueDate) "
    strSQL = strSQL & " VALUES('" & Me.Sender & "', '" & Me.Recipient & "', '" & Me.SeqNo & ", '" & Me.IssueDate & ");"

    dbs.Execute strSQL, dbFailOnError
    Set dbs = Nothing
    DoCmd.OpenQuery "UpdateTransNo"

    Exit Sub
    ErrHandler:
    MsgBox (Err.Description)
    rst.Close
    Set dbs = Nothing
    Exit Sub

    End Sub

  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
    It does not look like the SQL string will be valid. Generally, text values need to be surrounded by single quotes, dates by # and numbers by nothing. The first two values you treat as text, but the second two both have single quotes before the value but nothing after. Don't know what your data types are, but certainly the inconsistent delimiters will be a problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TG_W is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    That was it. When I ran test runs before, I was typing in "aaa" just to see if it was working. Still getting the hang of VBA... Thanks!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    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. Event Calendar Help
    By Nosaj08 in forum Forms
    Replies: 9
    Last Post: 06-11-2010, 11:19 AM
  2. Event procedures
    By GIS_Guy in forum Forms
    Replies: 1
    Last Post: 05-11-2010, 02:34 PM
  3. OnClick event
    By HotTomales in forum Forms
    Replies: 1
    Last Post: 12-24-2009, 08:10 PM
  4. Event question
    By nkenney in forum Forms
    Replies: 1
    Last Post: 07-01-2009, 11:34 PM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

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