Computer Learning Zone CLZ Access Excel Word Windows

Life is not divided into semesters. You don't get summers off, and very few employers are interested in helping you "find yourself."

-Bill Gates
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Access >
Back to TechHelp    Comments List
Upload Images   Link   Email  
On Load Visible
Giovanni Miranda 
    
15 months ago
I have this code:

Private Sub Form_Load()
    Me.AirportDiagramLoc.Visible = False
    Me.FirstChoiceAircraft.Visible = False
    Me.ProfilePicture.Visible = False
End Sub

So when I open the Form these 3 Fields are inactive, I have buttons to make them re-appear again but what I would like to do as well is when a key Field is empty or Null then I would like them to re-appear automatically.

When I add a new Record All the Fields are empty anyway, but keying a particular Field will also help me out when I've entered all the information in the Form itself and have left out entering in that one key Field.

I've tried coding an If Then Else statement but it does not work, this is what I coded to try:

Private Sub Form_Load()
    If InstallDate = Null Then
        Me.AirportDiagramLoc.Visible = True
        Me.FirstChoiceAircraft.Visible = True
        Me.ProfilePicture.Visible = True
    Else
        Me.AirportDiagramLoc.Visible = False
        Me.FirstChoiceAircraft.Visible = False
        Me.ProfilePicture.Visible = False
    End If
End Sub

I'm not sure if I have the right syntax at the beginning:

If InstallDate = Null Then

where InstallDate is the Field name and I'm trying to show it as "empty" or "Null".  I thought that it would work but all it does is as if there is no If Then Else and it just works as the original top code.
Kevin Robertson 
          
15 months ago
Use If IsNull(InstallDate) Then

Do you only need the code to run when the Form Loads?
Does it also need to run when you navigate through the records?
See: On Current
Giovanni Miranda OP 
    
15 months ago
I've tried that as well and, and it doesn't show the Fields when the Form is Open.  I got the True and False turned around it should be that when there is a Value in the IntallDate Field then the Fields are not visible, hence IsNull = True so I switched those around.  But, it does not show the Fields even when there is no Value in InstallDate.  This is the Code now, and yes it needs to follow from Record to Record as if for some reason the Value in InstallDate was deleted then the Fields would not be seen:

Private Sub Form_Load()
    If IsNull(InstallDate) Then
        Me.AirportDiagramLoc.Visible = True
        Me.FirstChoiceAircraft.Visible = True
        Me.ProfilePicture.Visible = True
    Else
        Me.AirportDiagramLoc.Visible = False
        Me.FirstChoiceAircraft.Visible = False
        Me.ProfilePicture.Visible = False
    End If
End Sub

Thanks for your help Kevin.
Kevin Robertson 
          
15 months ago
Try also checking for an empty string (this is different from Null).

If IsNull(InstallDate) Or InstallDate = "" Then

Since you need this to run when you move from record to record use the On Current event.
Also note: you don't need Me. throughout your code. See Bang! v Dot.
Giovanni Miranda OP 
    
15 months ago
I've tried that as well also, but...I also have tried putting it inside the On Current event and still not working.
Giovanni Miranda OP 
    
15 months ago
Kevin,

I've changed the Field to another Field Name just to see if there were any conflicts with any other code.  Could another Event Procedure be causing it not to work?  I changed my  code to this for a Field called AirportCode:

'Original Code which works
Private Sub IATA_or_ICAO_Code_Click()
    AirportDiagramLoc.Visible = False  
    FirstChoiceAircraft.Visible = False
    ProfilePicture.Visible = False
End Sub

So, now my code looks like this:

    If AirportCode = "" Then
        AirportDiagramLoc.Visible = True
        FirstChoiceAircraft.Visible = True
        ProfilePicture.Visible = True
    Else
        AirportDiagramLoc.Visible = False
        FirstChoiceAircraft.Visible = False
        ProfilePicture.Visible = False
    End If

Could the "FieldName.Visible = " be the wrong syntax to use in this case?  And, if it possibley is what would be the correct syntax?

I took your advice and took a look at Bang! v Dot so I took the Me. out since it is on the same Form anyway, thanks for that.
Giovanni Miranda OP 
    
15 months ago
Sorry,

IATA_or_ICAO_Code was changed to AirportCode...

This thread is now CLOSED. If you wish to comment, start a NEW discussion in TechHelp.
 

 
 
 

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 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/13/2024 10:12:49 AM. PLT: 1s