Solved

Syntax for reference control on subform datasheet

Posted on 2011-09-29
4
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

726 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