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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|