Share via

Test subform control for null value

Anonymous
2012-04-02T19:12:03+00:00

On my main form I have control how the user exits the form by using a Cancel and Finished button. As part of the code for the Finished button I have code that tests for missing data.

I also need to check 2 controls (cboCalibrationCycle and cmdCalibrationCompleted) on my subform (subCalibrationHistory) but can not get the syntax correct

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2012-04-02T20:21:41+00:00

    You can do something like

        If IsNull(Me.subCalibrationHistory!cboCalibrationCycle) Then

            Me.subCalibrationHistory.SetFocus

            Me.subCalibrationHistory!cboCalibrationCycle.SetFocus

            MsgBox "Please select a calibration cycle."

            Exit Sub

        End If

        If IsNull(Me.subCalibrationHistory!txtCalibrationCompleted) Then

            Me.subCalibrationHistory.SetFocus

            Me.subCalibrationHistory!txtCalibrationCompleted.SetFocus

            MsgBox "Please enter a value for calibration completed."

            Exit Sub

        End If

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-04-02T19:28:56+00:00

    Sorry I should have named cmdCalibrationCompleted txtCalibrationCompleted it is just a date field.

    The purpose of this form is to add new equipment to the inventory. So in this case the subform record is blank (new)

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2012-04-02T19:15:24+00:00

    A subform can - in theory - contain many records, so what do you want to check? Whether cboCalibrationCycle is null on all records? Or on at least one record?

    And what is cmdCalibrationCompleted? cmd is mostly used as prefix for command buttons, but command buttons do not have a value.

    Was this answer helpful?

    0 comments No comments