?
Solved

VB/Access Referential Integrity

Posted on 2008-10-29
4
Medium Priority
?
230 Views
Last Modified: 2012-05-05
Experts,

I just set up a relationship in Access between two tables that enforces one-to-many referential integrity.  When I tried to delete the parent record from the query window, I was warned that I would leave orphans in the child table, as I should be.

When I run the same query from my VB code, it doesn't delete the parent record (which is good), but it never throws any kind of error telling me I'm about to screw up the database.  Is there any way I can have the VB program let me know when a potential violation of referential integrity is about to take place?
0
Comment
Question by:NigelRocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 2000 total points
ID: 22833619
When you executed the query, the execute function should have at least returned something letting you know that nothing is getting changed.  I know in the case of DAO, the DB.Execute( SQL$ ) function returns a number indicating the number of records modified.
The other possibility might be bad error handling (like an "On Error Resume Next" that is catching any error getting thrown).
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22834068
No error is generated to be caught in "On Error".

As far as the return value on an execute, does anyone know how to do that in ADO?

0
 
LVL 16

Assisted Solution

by:HooKooDooKu
HooKooDooKu earned 2000 total points
ID: 22834616
If you are using ADODB (Microsoft ActiveX Data Objects X.X Library),
ADODB.Execute has a parameter for which the number of records affected is passed by reference.

...
Dim RecordsModified as long
Dim DB as ADODB
Dim SQL$
...
DB.Execute( SQL$,RecordsModified, adCmdText )
if RecordsModified = 0 then
    MsgBox "Nothing was modified"
End If
...

Open in new window

0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22891967
I hate to bother you again, but I don't see how this works in ADO.  I don't see that ".execute" has a return value.  What am I missing?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question