Solved

Using macros with navigation forms in Access 2010

Posted on 2014-03-05
7
1,682 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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 functions 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 Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now