Solved

allowedits in subform syntax

Posted on 2014-02-13
8
449 Views
Last Modified: 2014-02-13
Dear experts  -
Hopefully simple...

I have 2 subforms on a form. In the current event on the one subform I want to control the allowedits on the other.

The following line is giving me the error "method or data member not found"

Forms!Main_Form!sfQuickView2.Form.AllowEdits = IIf(Nz(Forms!Main_Form!txtContact_ID, 0) <> 0, True, False)

sfQuickView2 is the control name of the other subform; the source object of that subform is also changed programmatically elsewhere (which is working fine).

Thanks!
0
Comment
Question by:terpsichore
  • 4
  • 3
8 Comments
 

Author Comment

by:terpsichore
Comment Utility
CORRECTION - this error is only occurring THE FIRST TIME THE FORM LOADS. Any fixes? THANKS
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
where are you executing the code?
0
 

Author Comment

by:terpsichore
Comment Utility
in the current event of the (first) subform
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
where is the subform "sfQuickView2" located ?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:terpsichore
Comment Utility
there is one main form (main_form), which has 2 subforms (on the same page): sfcontacts (whose Current event is firing the code above) and sfQuickView2
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
Comment Utility
<THE FIRST TIME THE FORM LOADS>
the problem is,
you are calling the code in the current event of the subform "sfcontacts",
at this event, the Main form hasn't loaded yet, that is why the error  "method or data member not found" is triggered.

try calling the codes with an "If <....  >  Then "  condition
0
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
Comment Utility
Curious why that code is not in the Main Form?  It seems like it is better suited for the main form.  You could place it in the Main Form's Current event (which would avoid the error on Loading issue) and in the After Update event of txtContact_ID (to respond to changes in that field).  The code would look like this in both of those events:

 Me.sfQuickView2.Form.AllowEdits = IIf(Nz(Me.txtContact_ID, 0) <> 0, True, False)

Open in new window



If you absolutely need that code in the subform current event, then you can also use error handling -- which sshould always be a part of your code anyway.  Since the error only occurs when the form opens, It is safe to simply exit the sub if that error is raised  (see my inline comments in the code):


Private Sub Form_Current()
     On Error Goto EH

    Forms!Main_Form!sfQuickView2.Form.AllowEdits = IIf(Nz(Forms!Main_Form!txtContact_ID, 0) <> 0, True, False)

     exit sub

EH:
    If Err.Number = 1234   then exit sub '<---*** Replace with the actual error code you are seeing
    msgbox "Error " & err.Number & ": " & err.description
End Sub]

Open in new window

0
 

Author Closing Comment

by:terpsichore
Comment Utility
superb and insightful feedback.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

728 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

12 Experts available now in Live!

Get 1:1 Help Now