View Single Post
  #3  
Old February 6th, 2008, 06:24 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default table not updating

On Wed, 6 Feb 2008 07:43:02 -0800, Ra wrote:

I am adding records to tblEmployees using below, no connection:
strAddRecord="INSERT INTO tblEmployees() VALUES ()"
DoCmd.RunSQL strAddRecord


So you're adding no data into no fields????

and this works fine. I then open the same table, over connection:
Call ConOpen
rst.Open "tblEmployees", con, adOpenStatic, adReadOnly
rst.MoveLast
lngEmployeeID=rst!EmployeeID
Then, I add records to a second table (tblB) using the lngEmployeeID as id.
Same syntax, no connection:
strUpdateB = "INSERT INTO tblB() VALUES ()"
DoCmd.RunSQL strUpdateB
The issue is that the lngEmployeeID does not always update to the last
record,


Why would you expect it to do so? You're not specifying the value to be
inserted.

and at that point it uses the previous lngEmployeeID for the next 4-5
entries in tblB. Then it jumps to the correct id and everything goes back to
normal.
So when I pull up an employee name in this range of id's, I only get the
info from tblEmployees and nothing from tblB, due to different is numbers.


If you're trying to have Autonumbers synchronized between two tables - and
this is really unclear to me, since you're evidently not posting the actual
code you're using! - you're on the wrong track. Your tblB should NOT have an
autonumber EmployeeID; it should instead have a Long Integer. Also, rather
than opening a recordset, why not just run an Append query from tblEmployees
into tblB???

John W. Vinson [MVP]