Results 1 to 4 of 4
  1. #1
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368

    Insert statement fail

    Hi guys,

    if i use this INSERT it works fine :

    Code:
    strSQL = "Insert into tblParkeerbeheer_log select * from parkeerbeheer where [ID] = " & Forms![parkeerbeheer]![fldID].Value & ""
    DoCmd.RunSQL strSQL
    But if i want to do the same with multiple records with Pnummer (personell number) as criteria in the WHERE clause :

    Code:
    strSQL = "Insert into tblParkeerbeheer_log select * from parkeerbeheer where [Pnummer] = " & Forms![parkeerbeheer]![Pnummer].Value & ""
    DoCmd.RunSQL strSQL
    It asks me to prompt the personell numer, while that number is present within the prompt box


    Click image for larger version. 

Name:	Prompt.jpg 
Views:	13 
Size:	12.2 KB 
ID:	16259

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    where [Pnummer] = '" & Forms![parkeerbeheer]![Pnummer].Value & "'"

    You need to enclose the data returned by the variable within single quotes if the variable returns literal text.

  3. #3
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Hi Itsme,

    Indeed that was the problem.

    Many thanks !

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Glad you were able to solve the problem.

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

Similar Threads

  1. INSERT statement
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 03-29-2013, 12:53 PM
  2. Insert Into statement
    By TimMoffy in forum Programming
    Replies: 7
    Last Post: 07-13-2012, 07:10 AM
  3. Insert statement
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 08-19-2011, 02:20 PM
  4. Help about access INSERT INTO statement
    By ducthang88 in forum Programming
    Replies: 7
    Last Post: 12-03-2010, 08:40 AM
  5. Replies: 4
    Last Post: 09-03-2010, 02:55 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