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 / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Validate value exists in another table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J - 14 Mar 2005 23:51 GMT
I have a field in a sub-form where I want to validate that the value they
enter is a valid record in a different table. I’m not using a drop down
because the list could grow considerably. I am enforcing referential
integrity through table relationships but I would like to cancel/undo the
transaction if this occurs. How can I accomplish this?
JaRa - 15 Mar 2005 00:13 GMT
You could use the BeforeInsert and/or beforeupdate event in the subform.
Their you can check whether the value exists in the other table if not you
can cancel the update.

- Raoul

> I have a field in a sub-form where I want to validate that the value they
> enter is a valid record in a different table. I’m not using a drop down
> because the list could grow considerably. I am enforcing referential
> integrity through table relationships but I would like to cancel/undo the
> transaction if this occurs. How can I accomplish this?
J - 15 Mar 2005 16:29 GMT
Thanks, I should have been more specific about my request. It's the code I
need for the BeforeUpdate event. My VB is pretty weak. I saw some sample code
in another application with one difference being that in my case it's a
subform and the following example is not:
Dim str As String
str = Me.ComponentID
   If IsNull(DLookup("[PartID]", "tblMfg", "[PartID]=  '" & str & "'")) Then
       MsgBox "Component does not exist, check name"
       DoCmd.RunCommand acCmdUndo
       Cancel = True
   End If

> You could use the BeforeInsert and/or beforeupdate event in the subform.
> Their you can check whether the value exists in the other table if not you
[quoted text clipped - 7 lines]
> > integrity through table relationships but I would like to cancel/undo the
> > transaction if this occurs. How can I accomplish this?
 
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.