Senin, 26 September 2011

RE: [MS_AccessPros] Insert Into Syntax help

Doyce,
Try this:
strSQL = "Insert INTO [WordsDrawn](ID, Contestants) Values (" & intWDID & ", """ & strWord & """)"
Debug.Print strSQL

Duane Hookom
MS Access MVP

To: MS_Access_Professionals@yahoogroups.com
From: winberry.doyce@roadsysinc.com
Date: Mon, 26 Sep 2011 20:44:10 +0000
Subject: [MS_AccessPros] Insert Into Syntax help


Hello friends!

John Viescas, nice to see you posting. Hope you had a good time doing whatever you were off doing.

I'm trying to capture a value from a form and a calculated value and save them into a table using Insert Into but can't seem to get the syntax correct. I've verified both values as working correctly through the immediate window, however I can't seem to save them in a table. The table has only 2 fields, ID and Contestant. I'm using the following code:

'Save word to WordsDrawn Table
Dim intWDID As Integer
Dim strWord As String
Dim strSQL As String

intWDID = Nz(DMax("ID", "WordsDrawn") + 1, 1)
Debug.Print intWDID

strWord = Me.txtName
Debug.Print strWord
strSQL = "Insert INTO [WordsDrawn](ID, Contestants) Values (intWDID, strWord)"
Debug.Print strSQL

Dim db As DAO.Database
'Point to this database
Set db = CurrentDb

CurrentDb.Execute strSQL, dbFailOnError

When I execute this code I get a runtime error 3601: Too few parameters. Expected 2.

I appreciate any help.

Doyce


[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MS_Access_Professionals/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/MS_Access_Professionals/join
(Yahoo! ID required)

<*> To change settings via email:
MS_Access_Professionals-digest@yahoogroups.com
MS_Access_Professionals-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
MS_Access_Professionals-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Tidak ada komentar:

Posting Komentar