Solved

Using macros with navigation forms in Access 2010

Posted on 2014-03-05
7
1,838 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

730 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