Solved

Syntax for reference control on subform datasheet

Posted on 2011-09-29
4
240 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 119

Accepted Solution

by:
Rey Obrero 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

746 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