object does not contain automation object form- error

  • Thread starter Thread starter vandy
  • Start date Start date
V

vandy

Hi,

I have a form which contains list of customers unique with the ID feild.
I have set the CustomerID to hyperlink and when the user clicks on that it
opens up the selected detail of the customer in a dialog window were the user
can change the values.
Macro used.
Action: open form
Argument: Customer Details
View: form
Where Condition: ="[ID]=" & Nz([ID],0)
Window Mode: Dialog

condition: Not IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, [ID]

condition: IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)

Action:
requery
SearchForRecord
Arguments: , , First, ="[ID]=" & [TempVars]![CurrentID]

Action: RemoveTempVar
Arguments: CurrentID

The macro works but when i run the macro it gives the msg

The object doesn't contain the Automation object 'form'.

how can i correct this.
 
Vandy,

First of all, it seems to be a moot point, because, as I understand it,
this is related to clicking the ID, so therefore [ID] will never be
Null, because if it was then you wouldn't be clicking it. Am I right?
If so, this whole section of the macro is not applicable and can be removed:
condition: IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)

Having said that, in fact, looking more closely at what you have done, I
don't quite understand anyway. The very first action opens the Customer
Details form *at the record matching the current [ID]*. And then the
rest of the macro is aimed at finding the record within that form
matching the current [ID]. But you're already there... see what I mean.
Looks like unnecessary steps to me.

But if I have misunderstood, and if you really do need that stuff in
there, then I suggest changing this like:
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)
....to:
Arguments: CurrentID, Nz(DMax("[ID]","YourQuery"),0)
(Where YourQuery is the name of the table or query that is the Record
Source of the form.)

You should consider also whether your use of the Nz() function here is
legitimate. It is potentially returning a value of 0 but I imagine you
do not have a record in your table where the value of the [ID] field is 0.
 
Thanks Steve,

Point noted. There was a lot of unnecessary code.

I have another scenario just like the one mentioned here only difference i
have a combo box in my header section called Go To were I am displaying 3
columns of the data by a query.

When i click on the Go To the respective record must be displayed on the
detail section. how can i acheive this using a macro.

Any help would be appreciated.
thanks

Steve Schapel said:
Vandy,

First of all, it seems to be a moot point, because, as I understand it,
this is related to clicking the ID, so therefore [ID] will never be
Null, because if it was then you wouldn't be clicking it. Am I right?
If so, this whole section of the macro is not applicable and can be removed:
condition: IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)

Having said that, in fact, looking more closely at what you have done, I
don't quite understand anyway. The very first action opens the Customer
Details form *at the record matching the current [ID]*. And then the
rest of the macro is aimed at finding the record within that form
matching the current [ID]. But you're already there... see what I mean.
Looks like unnecessary steps to me.

But if I have misunderstood, and if you really do need that stuff in
there, then I suggest changing this like:
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)
....to:
Arguments: CurrentID, Nz(DMax("[ID]","YourQuery"),0)
(Where YourQuery is the name of the table or query that is the Record
Source of the form.)

You should consider also whether your use of the Nz() function here is
legitimate. It is potentially returning a value of 0 but I imagine you
do not have a record in your table where the value of the [ID] field is 0.

--
Steve Schapel, Microsoft Access MVP
Hi,

I have a form which contains list of customers unique with the ID feild.
I have set the CustomerID to hyperlink and when the user clicks on that it
opens up the selected detail of the customer in a dialog window were the user
can change the values.
Macro used.
Action: open form
Argument: Customer Details
View: form
Where Condition: ="[ID]=" & Nz([ID],0)
Window Mode: Dialog

condition: Not IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, [ID]

condition: IsNull([ID])
Action: SetTempVar
Arguments: CurrentID, Nz(DMax("[ID]",[Form].[RecordSource]),0)

Action:
requery
SearchForRecord
Arguments: , , First, ="[ID]=" & [TempVars]![CurrentID]

Action: RemoveTempVar
Arguments: CurrentID

The macro works but when i run the macro it gives the msg

The object doesn't contain the Automation object 'form'.

how can i correct this.
 
Vandy,

You would use the FindRecord action in your macro for this.

With the FindRecord action, you first of all need to use a GoToControl
action to set the focus to the applicble control in the Detail section.
This will depend on what is the "BoundColumn" of the Go To combobox.
 
HI Steve,

Thanks for your answer. I tried the macro and am not able to get the desired
result.

I have a combo box cboGoToContact which accepts values based on a query with
the bound column being ID

My Macro reads like this:

GoToControl :cboGoToContact

FindRecord:
FindWhat - cboGoToContact.ID
Match: whole field
Match case - no
search - all
search as formatted - yes
only current field-yes
find first - yes

I think i should enter something else in find what. How can i go to the
desired value when i select the value from the combo box.

thanks for your time and patience.
 
Vandy,

No, it is actually simpler than you are interpreting.

Action: GoToControl
Control Name: [ID]

Action: FindRecord
Find What: =[cboGoToContact]

This assumes you have an [ID] control, visible and enabled, in the
detail section of the form, based on the [ID] field in the form's
underlying record source. If you haven't, I don't think FindRecord will
work.
 
Back
Top