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 / Macros / March 2007

Tip: Looking for answers? Try searching our database.

Problem with Set Value in Subform - The object doesn't contain the Automation...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angela_Marie - 27 Mar 2007 00:16 GMT
I am attempting to create a macro in a subform that will automatically set
the value for a field and I keep getting the error message "The object
doesn't contain the automation object 'Patient Insurance Table'". I have read
several postings on this subject but I still cannot figure out what I am
doing incorrectly.  Here are the details:
I have a tabbed form with several subforms. One of the subforms is based on a
Query that includes the tables "Insurance Table" and "Patient Insurance
Table".  The Patient Insurance Table has a Primary key named "Patient ID#"
and a foreign key named "Insurance#". I want each insurance for a particular
Patient ID# to be numbered sequentially for that patient only. So, the first
insurance added for a patient should be numbered 1 and the next to be
numbered 2 and so on... The reason that the Insurance Table is included in
the subform query is because I have information from that table populating
the form when a particular insurance is selected.

The macro is written as follows:
SetValue
Item: [PATIENT INSURANCE TABLE]![Insurance#]
Expression: Nz(DMax("[Insurance#]","Patient Insurance Table","[Patient
Insurance Table].[Patient ID#]=" & [Patient Insurance Table].[Patient ID#]),0)
+1
Event: BeforeUpdate

I look forward to being embarrassed by how easy this is to fix!
Thank you!
Steve Schapel - 27 Mar 2007 00:42 GMT
Angela Marie,

This doesn't quite hold together.  You are trying to assign a value to a
field which is the foreign key field, but kind of using it as a type of
serialising number.  So that means the primary key in the Insurance
table is being used to serial number the Patient Insurance records.  Is
that right?

By the way, it is not a good idea to use a # as part of the name of a field.

And in direct answer to your question (though I think there is a design
problem to be resolved first), the arguments of the SetValue macro
action should be like this...
Item: [Insurance#]
Expression: Nz(DMax("[Insurance#]","Patient Insurance Table","[Patient
ID#]=" & [Patient ID#]),0)+1

Signature

Steve Schapel, Microsoft Access MVP

> I am attempting to create a macro in a subform that will automatically set
> the value for a field and I keep getting the error message "The object
[quoted text clipped - 21 lines]
> I look forward to being embarrassed by how easy this is to fix!
> Thank you!
 
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.