Hello everyone.
I'm trying to construct a database in Microsoft Access 2003. The first person that is going to use the database wishes to do all her work in Excel and then the database is supposed to be updated by importing the Excel document into my Access database. This means that I will have a big table that is imported from Excel. Since I'm pretty sure that later users will want to be able to update things directly in the database, I'm trying to split up the big table into smaller tables to make the database a little more manageable. As a part of this I want to check for a text in the big table, find the same text and a corresponding ID number in a sub table and in a third table save the ID number. To do this I have written the following code where the big table is "Hazard List Bridge", the sub table is "subTbl_LinkSpe cific" and the table where the result should be stored is "tbl_Hazard ".
As mentioned in the code I have omitted parts of the code but that code is working fine and the problem comes when I'm trying to open the recordset with the SQL string strSQLLinkSpeci fic (line 16). I get the following error:
"Run-time error 3061 - Too few parameters. Expected 1"
Clearly something is wrong with the way I'm trying to open a recordset but do you have any idea what I should change to be able to do what I want, i.e. check for a text in the big table, "Hazard List Bridge", find the same text and a corresponding ID number in a sub table, "subTbl_LinkSpe cific", and in a third table, "tbl_Hazard ", save the ID number?
Sincerely
Adam Krusk
PS
ID_LinkSpecific and SpecifikOrGener al are columns in subTbl_LinkSpec ific and "Hazard List Bridge" if that was unclear.
DS
I'm trying to construct a database in Microsoft Access 2003. The first person that is going to use the database wishes to do all her work in Excel and then the database is supposed to be updated by importing the Excel document into my Access database. This means that I will have a big table that is imported from Excel. Since I'm pretty sure that later users will want to be able to update things directly in the database, I'm trying to split up the big table into smaller tables to make the database a little more manageable. As a part of this I want to check for a text in the big table, find the same text and a corresponding ID number in a sub table and in a third table save the ID number. To do this I have written the following code where the big table is "Hazard List Bridge", the sub table is "subTbl_LinkSpe cific" and the table where the result should be stored is "tbl_Hazard ".
Code:
Dim rstHazardsFromExcel As DAO.Recordset
Dim rstHazard As DAO.Recordset
Dim rstLinkSpecific As DAO.Recordset
Dim strSQLLinkSpecific As String
'Here is code that is working fine and that is not relevant to the question
Set rstHazardsFromExcel = curDatabase.OpenRecordset("Hazard List Bridge")
Set rstHazard = curDatabase.OpenRecordset("tbl_Hazard")
With rstHazardsFromExcel
For Each fld1 In .Fields
Do Until .EOF
rstHazard.AddNew
strSQLLinkSpecific = "SELECT KEY_LinkSpecific FROM subTbl_LinkSpecific, [Hazard List Bridge] WHERE ID_LinkSpecific = SpecifikOrGeneral"
Set rstLinkSpecific = curDatabase.OpenRecordset(strSQLLinkSpecific, dbOpenDynaset)
rstHazard![ID_LinkSpecific] = rstLinkSpecific![KEY_LinkSpecific]
rstHazard.Update
.MoveNext
Loop
Next
End With
'Here is code that is working fine and that is not relevant to the question
As mentioned in the code I have omitted parts of the code but that code is working fine and the problem comes when I'm trying to open the recordset with the SQL string strSQLLinkSpeci fic (line 16). I get the following error:
"Run-time error 3061 - Too few parameters. Expected 1"
Clearly something is wrong with the way I'm trying to open a recordset but do you have any idea what I should change to be able to do what I want, i.e. check for a text in the big table, "Hazard List Bridge", find the same text and a corresponding ID number in a sub table, "subTbl_LinkSpe cific", and in a third table, "tbl_Hazard ", save the ID number?
Sincerely
Adam Krusk
PS
ID_LinkSpecific and SpecifikOrGener al are columns in subTbl_LinkSpec ific and "Hazard List Bridge" if that was unclear.
DS
Comment