Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / October 2003

Tip: Looking for answers? Try searching our database.

Resynch returs 0 for identity field (PK)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian Von?sch - 22 Oct 2003 13:39 GMT
Hi NG

I add a new record in a form.
The form's recordsource is a view "PrjSel":

CREATE VIEW PrjSel
WITH VIEW_METADATA
AS
SELECT *
FROM PrjTbl
WHERE (ForPrjManagersOnly=0) OR
(IS_MEMBER('PrjManagers') = 1)

The view shows all projects, if the current user is a member of the role
'PrjManagers'
If the user is not a member of this role, he only gets the projects NOT
ForPrjManagersOnly.

To avoid access to all projects to everybody I deny access to the table
PrjTbl directly:
DENY SELECT ON PrjTbl TO ALL

The WITH VIEW_METADATA in PrjSel is necessary to allow data addition in the
view through a form.
(Otherwise adp tries to add a record directly to the table, but if
select-access is denied it fails.)

The form's properties are:
RecordSource = "PrjSel"
Serverfilter = ""
UniqueTable = "PrjSel" (this works because of the WITH VIEW_METADATA!)
Resynch = "select * from PrjSel where PrjID=?"

Now the problem is, that the control which displays the PK: PrjID gets a 0
instead of the new identity-value.
Therefore my subform linked via PrjID (masterfields-childfields) doesn't
work and displays no record!
Only after requerying and jumping to the newly added record, the PrjID is
displayed correctly and the subform works.

Thank you for your help. (adp2000; SQL2000)

Christian Von?sch
Christian Von?sch - 23 Oct 2003 20:28 GMT
Hi NG

I answer to myself, if anybody is interested in the problem/solution:

I was not quite right in expressing my problem. By simplifying it for better
understandig, I simplifyed too much. The view, my form is based on joins two
tables. And that was the problem. It still makes no sense, that access
doesn't give back the correct (AutoNumber) Primary Key after resynch, but I
solved the problem by taking a view with only one table behind to add a new
record.

Bye
Chris

> Hi NG
>
[quoted text clipped - 39 lines]
>
> Christian Von?sch
Sylvain Lafontaine - 24 Oct 2003 20:45 GMT
Access have a lot of bugs when it come to multiple joined tables.

It often help to use stored procedures instead of views or user defined
functions.

S. L.

> Hi NG
>
[quoted text clipped - 54 lines]
> >
> > Christian Von?sch
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.