Solved

Syntax for reference control on subform datasheet

Posted on 2011-09-29
4
265 Views
Last Modified: 2012-05-12
On the main form, there is a print button.  Before printing, I need to validate the subform field is not null.

subform is called "sbfrmTransaction"

control is called "cboEmployeeCode"

Here is my code:

If IsNull(???) Then
    MsgBox "Employee code must be filled in before printing."
    Exit Sub
End If

1) What would the syntax be in the IsNull(???)

2) Subform is a datasheet, do I have to loop through all the records to validate each of these fields?
0
Comment
Question by:gcgcit
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36814896

if  Isnull(me.sbfrmTransaction.form.cboEmployeeCode) then
    MsgBox "Employee code must be filled in before printing."
    Exit Sub
End If


note: just make sure that the subform control name is "sbfrmTransaction"

0
 
LVL 61

Expert Comment

by:mbizup
ID: 36814897
Give this a try:

If IsNull(me.sbfrmTransaction.Form.cboEmployeeCode) Then
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36814907
< do I have to loop through all the records to validate each of these fields?>

If you are priniting a report, why not just create an Access report whose underlying query excludes nulls in that field (no code necessary)?
0
 

Author Closing Comment

by:gcgcit
ID: 36814930
Worked perfectly.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

856 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