?
Solved

Using macros with navigation forms in Access 2010

Posted on 2014-03-05
7
Medium Priority
?
1,943 Views
Last Modified: 2014-03-09
Hi ,

I have a form called interventions which I have set when I double click the IID field it opens up the form Update Register for that Intervention, it is working using a macro and the where action is just open form Setup Register  and the where clause is [IID]=[Forms]![Interventions]![IID].

This all works well until I place the form within a navigation forms and then the double click stops working.

Any idea why? I have only just started using navigation forms and they seem to be a pretty neat way to go.

Any help appreciated.

Tricia
0
Comment
Question by:tmckeating
[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
  • 4
  • 3
7 Comments
 
LVL 85
ID: 39909062
until I place the form within a navigation forms and then the double click stops working.
Generally this means you've placed it in a Subform, which means you have to refer to the object differently:

 [IID]=[Forms]![YourNavigationForm].[YourSubformCONTROL].[Form].[Interventions]![IID]

Where "YourSubformCONTROL" is the name of the Subform control on YourNavigationForm. It may or may not be named the same as the form you're using as the SourceObject - and in fact, if this is a Navigation Form, it most likely will not be. This trips up a lot of new developers, so be careful and make sure you're reviewing the properties for the correct object.
0
 

Author Comment

by:tmckeating
ID: 39910303
Ok I have tried the following and it does not work. I don't think I understand what the subformcontrol means is that a filed or the name of a form?

[IID]=[Forms]![Admin].[IID].[Form].[Interventions]![IID]

My navigation form with all the tabs on it is called admin. I have a tab on that called Interventions which lists the IID which is the primary key. when I click the IID in the interventions form I want it to open up the Update register form for this IID both forms have an IID field.

Thanks
0
 
LVL 85
ID: 39910456
The Subform Control is just another Control on the form, like a Textbox or Combo.

I can't tell you the exact code, since I don't know your object names or structure. But the syntax is like this:

Forms![ParentForm].[SubformCONTROL].Form.[YourField]

The word "Form" is the one thing you do NOT change in that statement.

So as an example, if I have a Form named "fCustomer", and I have a Subform CONTROL on that form named "scAddresses", and that Subform CONTROL houses a form named "fAddress", and I want to get the value of txPhone on the fAddress form, I'd do this:

Msgbox Forms![fCustomer].[scAddresses].Form.[txPhone]

Note I did NOT refer to the "fAddress" form directly - I got the "handle" for that from the Form object of the subform control named "scAddresses".
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:tmckeating
ID: 39910725
Sorry for being a complete numpty!. I don't think that works for my database if you open my admin form and go to the interventions tab. I want to double click the interventions ID (IID) and for the associated record to open on the update register form. I have attached so you can see.

I have attached it.
Star-Project.accdb
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1400 total points
ID: 39914724
Get rid of the macro (in fact, get rid of ALL those macros and use VBA).

Set your Double Click event of your "IID" textbox on the INterventions subform to "Event Procedure", then add code like this:

Private Sub IID_DblClick(Cancel As Integer)
DoCmd.OpenForm "Update Register", , , "IID=" & Me.IID
End Sub
0
 

Author Comment

by:tmckeating
ID: 39914885
I used to use VBA and in 2010 it seems to automatically want to use macros when you create action buttons.

Thanks for that.

Tricia
0
 
LVL 85
ID: 39915683
You can tell 2010 to default to using Event Procedures. In Access options, click "Object Designers" and find the "Form/Report design view" section, then check the box for "Always use event procedures".
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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