K
-Karl
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)
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)