Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    37

    Unanswered: strange problem !

    Hi I have a button that inserts the value in a textbox into a table. The sql looks fine to me, but the problem is when I click the button a box appears and you have to enter a value into this before it is inserted into the table .
    Code:
    Private Sub cmdAddGroup_Click()
        
        'Sql statement inserts the value entered in the text box into the group table
        AddGroupsql = "insert into [Group] (group_name) Values (" & txtNewGroup.Value & ")"
        
        'Runs the SQL statement
        DoCmd.RunSQL (AddGroupsql)
        
      
    
        
    End Sub
    JD

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi JD

    Try AddGroupsql = "insert into [Group] (group_name) Values ('" & me.txtNewGroup & "')"
    (there are some apostrophies in there).
    If it still doesn't work, let us know what the message is on the input box.
    Cheers
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Dec 2003
    Posts
    37
    hi Thanks for the reply. I still get the same box appearing with the amended code.

    When you click the button the box appears, as below
    Attached Thumbnails Attached Thumbnails error.JPG  
    Last edited by JD|; 05-15-04 at 12:31.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hmmm. I've set up a table with your names and also a form pretty well identical to yours: I get exactly the same error as you do with your code but it works perfectly with mine.

    try pasting this in over your other code (I know you have done this but lets do belts and braces):

    AddGroupsql = "insert into [Group] (group_name) Values ('" & txtNewGroup.Value & "')"

    The two red apostrophies are what I added and are the difference between my version working and it failing.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Dec 2003
    Posts
    37
    pootle flump

    Thank you so much I don't think i'd have ever got that trees and forest and all that.

    Thats one less worry


    Thanks again !!

    Jason

Posting Permissions

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