Solved

Using macros with navigation forms in Access 2010

Posted on 2014-03-05
7
1,795 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
  • 4
  • 3
7 Comments
 
LVL 84
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 84
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 350 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 84
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

856 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