A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Too few Paramets, expected 1 error



 
 
Thread Tools Display Modes
  #1  
Old July 17th, 2009, 06:03 AM posted to microsoft.public.access.forms
-Karl
external usenet poster
 
Posts: 15
Default Too few Paramets, expected 1 error

This seems to be a common issue but I have yet to understand why my
code doesn't work. thanks for the extra help!


Maybe I just mistyped something here but this is what I am trying to
do:
1) Insert data into table A (This works)
2) Query table A for the value that was just inserted so I can get the
ID of the record (This is the problem)


Code:

'Insert the Site Name
DBStr = "INSERT INTO Sites (Site) VALUES ('" & Text2.Value
& "')"
CurrentDb.Execute DBStr, dbFailOnError


'Now get the ID of the Site that you just entered
Dim dbl As DAO.Database
Dim rsNewTest As DAO.Recordset
Set dbl = CurrentDb()

strSQL = "Select Site from Sites where Site=" & Text2.Value
Set rsNewTest = dbl.OpenRecordset(strSQL, dbOpenDynaset)
  #2  
Old July 17th, 2009, 06:11 AM posted to microsoft.public.access.forms
-Karl
external usenet poster
 
Posts: 15
Default Too few Paramets, expected 1 error

Nevermind, I got ti finally. My DBStr was not properly made

'Now get the ID of the Site that you just entered

Dim dbl As DAO.Database
Dim rsNewTest As DAO.Recordset
Set dbl = CurrentDb()
DBStr = "Select ID, Site from Sites where Site='" &
Text2.Value & "'"
'MsgBox DBStr

Set rsNewTest = dbl.OpenRecordset(DBStr, dbOpenDynaset)

Do Until rsNewTest.EOF
MsgBox rsNewTest.Fields("ID") & " " &
rsNewTest.Fields("Site")
rsNewTest.MoveNext
Loop
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.