Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Pending Approval    Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 

Anonymous 
 
Donald Blackwell  @Reply  
       
4 days ago
Adrian

Does the code work for you or is there something we can help with?

You've said what you're trying to do and shown code that applies but you didn't indicate if you were just showing what youve done or if something isn't working. And, if not what isn't working, what errors do you get, etc.
Adrian Connolly  @Reply  
      
4 days ago
the code gets stuck from         Form.frmClientINDIV.ContactLabel.Caption = "INDIVIDUAL" onwards | with a run-time error 2465: application defined or object defined error.
Mind you this worked on the frmclientindiv form but not control through a another form
Donald Blackwell  @Reply  
       
4 days ago
Ahh, that explains it ;)

        Forms!frmClientINDIV!IsCorporate = False
        Form.frmClientINDIV.ContactLabel.Caption = "INDIVIDUAL"


Notice the difference in the lines of code after the IsCorporate = False line:

You went from having Forms bang (Forms!) to Form dot (Form.)

The bang indicates you're referencing a different form. The Form. refers to the current form you're on. So:

Forms!frmClientINDIV!IsCorporate = False --- tells Access/VBA to look for an open form (frmClientINDIV) and set a control (IsCorporate) to false.

Form.frmClientINDIV.ContactLabel.Caption = "Individual" tells Access/VBA to look for a control or property (frmClientINDIV) on the current form with a property (ContactLabel) and activate a method/event (Caption) with a value of "INDIVIDUAL".

If you change all of the Form. to Forms! you should see better results:

        Forms!frmClientINDIV!ContactLabel.Caption = "INDIVIDUAL"
        Forms!frmClientINDIV!MainName.Left = 4926.096 '8.688cm
        Forms!frmClientINDIV!MainName.Width = 1584.198  '2.794cm


Donald Blackwell  @Reply  
       
4 days ago
Also, you could reduce duplication and, IMO, make your code easier to read if you use a "With" Block:

Private Sub BizStructureFrame_AfterUpdate()
    
     DoCmd.OpenForm "frmClientINDIV"
' opens "frmClientINDIV" form to enter a new record
   'DoCmd.OpenForm "YourFormName", DataMode:=acFormAdd
'if the button is Business then the objects for individual are set to false, while one of 'them is repositioned and resized

     With Forms!frmClientINDIV
          If BizStructureFrame <> 1 Then
               !Title.Visible = False
               !Label3.Visible = False
               !FirstName.Visible = False
               !Label4.Visible = False
               !MiddleName.Visible = False
               !Label5.Visible = False
          End If
          Select Case BizStructureFrame
               Case 1
               'ME.RecordSource = SELECT * FROM dbtClient WHERE (IsCorporate = False) ORDER BY MainName, FirstName;
                    !IsCorporate = False
                    !ContactLabel.Caption = "INDIVIDUAL"
                    !MainName.Left = 4926.096 '8.688cm

... The Rest of your code


     End With

End Sub


Adrian Connolly  @Reply  
      
3 days ago
thanks, i did try that approach but still had the same result, then i placed the code in brackets, Forms("frmClientINDIV")("FirstNameLab").Visible = False
when true it works, but as a false narative runtime error 2165 ýou can't hide a control that has the focus'
Donald Blackwell  @Reply  
       
3 days ago
Yeah, Access won't let you hide a control that has focus so that field probably gets focus when your form opens. To get around that, you can move the focus to a different field before you start hiding controls:

Forms(YOURFORM)(ACONTROLTHATWILLREMAINVISIBLE).setFocus

Then continue hiding controls.
Adrian Connolly  @Reply  
      
2 days ago
is there a sample to look at as that did not appear to work. sorry to bother you, i don't what the hell i'm doing wrong
Donald Blackwell  @Reply  
       
2 days ago
Hmm, did you get any errors when you tried it? The one thing I omitted, replace YOURFORM with the name of your form, and ACONTROLTHATHWILLREMAINVISIBLE with the name of a control on that formand, and, doh, I didin't put those in quotes, as I should have.

So to move more to your form's naming:

Forms("frmClientINDIV")("ACONTROLTHATWILLREMAINVISIBLE").SetFocus

Another option so you don't have to worry about which controls are going to be visible depending on the state of the business, for instance, Individual, Partnership, etc., you could put a transparent button on the form somewhere. I usually put it as the first control in the tab order, that way, once I've hidden fields and shown fields, as soon as the user presses tab, they'll go to the first visible control.

So then, right after the form opens, for example, if you have a transparent button named "FocusBtn":

Forms("frmClientINDIV")("FocusBtn").SetFocus

Then let your code hide and show controls as needed while that button has focus. You could even add another SetFocus at the end of each section to move the Focus to the first visible field if you wanted so the user isn't confused.

Donald Blackwell  @Reply  
       
2 days ago
Ugh, sorry, don't know why I clicked Bold instead of Code that last time :(
Kevin Robertson  @Reply  
           
36 hours ago
Fixed it for you Donald
Adrian Connolly  @Reply  
      
36 hours ago
thanks, sorry i could not see the trees for the forest
Add a Reply Upload an Image
Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/12/2026 4:34:21 PM. PLT: 0s