Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Validating field within print single record code

Discussion in 'Information Technology' started by Karl H, Nov 7, 2005.

  1. Karl H

    Karl H
    Expand Collapse
    Guest

    Hi,
    This code worked for a while, then stopped. I'm trying to be sure the
    client completes a "Limitation" field called cboLimits, before printing, and
    I have the following code:

    If Me.Dirty Then 'Save any edits.
    Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
    Msgbox "Select a record to print"
    Else
    strWhere = "[ID] = " & Me.[ID]
    If cboLimits = "" Then
    Msgbox "Enter limitations, if any."
    Me.cboLimits.SetFocus
    Exit Sub
    Else
    DoCmd.OpenReport strReport, acViewPreview, , strWhere
    End If
    End If
    End Sub

    It doesn't seem to be evaluating the cboLimits field, and just prints an
    empty space in the field on the report.

    Am I missing something?

    Thank you,
    Karl
     
  2. Loading...


  3. Karl H

    Karl H
    Expand Collapse
    Guest

    Hi Ofer,
    That worked great. I'll have to read up on what Len means.. Thank you so
    much!
    Karl

    "Ofer" wrote:

    > Just incase the value of the combo is Null and not empty, then try this
    >
    > If Len("" & Me.cboLimits) = 0 Then
    > Msgbox "Enter limitations, if any."
    > Me.cboLimits.SetFocus
    > Exit Sub
    > Else
    > DoCmd.OpenReport strReport, acViewPreview, , strWhere
    > End If
    >
    > --
    > The next line is only relevant to Microsoft''s web-based interface users.
    > If I answered your question, please mark it as an answer. It''s useful to
    > know that my answer was helpful
    > HTH, good luck
    >
    >
    > "Karl H" wrote:
    >
    > > Hi,
    > > This code worked for a while, then stopped. I'm trying to be sure the
    > > client completes a "Limitation" field called cboLimits, before printing, and
    > > I have the following code:
    > >
    > > If Me.Dirty Then 'Save any edits.
    > > Me.Dirty = False
    > > End If
    > >
    > > If Me.NewRecord Then 'Check there is a record to print
    > > Msgbox "Select a record to print"
    > > Else
    > > strWhere = "[ID] = " & Me.[ID]
    > > If cboLimits = "" Then
    > > Msgbox "Enter limitations, if any."
    > > Me.cboLimits.SetFocus
    > > Exit Sub
    > > Else
    > > DoCmd.OpenReport strReport, acViewPreview, , strWhere
    > > End If
    > > End If
    > > End Sub
    > >
    > > It doesn't seem to be evaluating the cboLimits field, and just prints an
    > > empty space in the field on the report.
    > >
    > > Am I missing something?
    > >
    > > Thank you,
    > > Karl
     

Share This Page