473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to set subform.visible = false, If subform control value is nothing?

In MS Access 2007, I have a vehicle information form. On my form is an equipment subform. The two forms are linked by V_ID (vehicle id). In the Form Current of my parent form I want to set the subform to only be visible if there is a value in the V_ID. Here's what I've tried, but it always evaluates to true even if the value is nothing.
Expand|Select|Wrap|Line Numbers
  1.  
  2. If Me!Equipment.Form!V_ID Is Nothing Then
  3.     Me.Equipment.Visible = False
  4. Else
  5.     Me.Equipment.Visible = True
  6. End If
  7.  
  8.  
Feb 3 '11 #1
6 6961
TheSmileyCoder
2,322 Expert Mod 2GB
Welcome to Bytes. Instead of Is Nothing, try:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me!Equipment.Form!V_ID) Then
Feb 3 '11 #2
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   If Not Me.NewRecord Then        'Not sure how you want to handle a New Record
  3.     Me!Equipment.Visible = Not IsNull(Me![Equipment].Form![V_ID])
  4.   End If
  5. End Sub
Feb 3 '11 #3
mshmyob
904 Expert 512MB
"IS NOTHING" is more of a vb or vb.net reference where vba uses the "ISNULL" function to test for nulls as TSO pointed out.

cheers,
Feb 3 '11 #4
Thanks. Tried your code, but subform is still visible even if there is no equipment record for the vehicle.
Feb 3 '11 #5
The message box always says "not null"
Expand|Select|Wrap|Line Numbers
  1. '*****TRYING TO MAKE SUBFORM INVISIBLE IF THERE IS NO EQUIPMENT RECORDS FOR THE VEHICLE ****
  2. If IsNull(Me![Equipment].Form![V_ID]) Then
  3.     MsgBox "null"
  4. Else
  5.     MsgBox "not null"
  6. End If
  7.  
Feb 3 '11 #6
mshmyob
904 Expert 512MB
Reference the whole form like so

Expand|Select|Wrap|Line Numbers
  1. If IsNull(Forms!yourParentFormName!Equipment.Form.[V_ID]) Then 
  2.     MsgBox "null" 
  3. Else 
  4.     MsgBox "not null" 
  5. End If
  6.  
DO NOT use "ME" when referencing a subform name in AC2007.

cheers,
Feb 3 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: awightma | last post by:
Hi, I have a datagrid with a number of textboxes on it. I want one column of my table to be visible=false because it contains the id of the record from the table. For some reason when I set...
0
by: Sabine Oebbecke | last post by:
Hi Experts! I have several forms and reports where controls get their values with 'Forms!MainForm!Control' or 'Forms!MainForm!Subform!Control' resp 'Forms!MainForm!Subform.Form!Control' which...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
10
by: Sally | last post by:
When I click on a control in a subform, what is the syntax to return the name of the subform control on the main form that contains the subform? MsgBox "MySubform is in " & < ???? > Thanks, ...
4
by: Gerry Abbott | last post by:
Hi all, A subForm control, txtTotalSubForm contains a total from one of the fields on this subForm . The mainForm contains a combo, myCombo which filters, and updates the details on the subForm. I...
1
by: MLH | last post by:
I have a form with a subform control on it listing records returned by a saved query named UnbilledVehicles. I would like to put command buttons on the main form to apply dynamic filters to the...
8
by: kevin.vaughan | last post by:
Good Afternoon Everyone, Could someone please explain why I can't set the Subform control Visible attribute to False as below? The statement for the locked attributes work but not for the...
7
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm...
1
by: veteranwebdesign | last post by:
Hello, I have a main form. I want forms to open in a subform control box. What is the code for the option group to open the subforms in the control box. I didn't create subforms, I created...
2
by: lenniekuah | last post by:
Hullo Good Friends, I need your help. Please Help me. I am trying to pass the name of the Calling FORM FRMSALES to the Loaded FORM FRMPOPUPCustomers so that FRMPOPUPCustomer will set the FRMSALES...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.