Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2004
    Posts
    63

    Unanswered: Check whether a subform has data.

    Hello all,

    I have a subform (datasheet) with an onClick that shows details of the current record in another subform. It works fine, only when the form loads, the form is blank until an action is taken by the user to populate the first subform.

    Is their a way of checking if a subform has data in code?
    eg calling on a module:

    If hasData (Me.SubOne) = True then

    or like in reports "On no data" action.

    Thanks,
    ChrisOfCatford

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Yes, you have to look at specific fields in the sub form for data.

    if isNull(Forms!SubOne!somefield) then
    action...
    else
    action..
    end if

  3. #3
    Join Date
    Sep 2004
    Posts
    63
    Hi,

    Thanks for your reply.

    I tried that but I get a "You entered an expression that has no value".

    Here is code as it stands onClick of anywhere in the form.

    Dim strMsg As String

    If IsNull(Me.PupilID) = False Then
    strMsg = Me.PupilID
    Forms!frmPupilSelector!txtSelected = strMsg
    Forms!frmPupilSelector!txtPupilName = Me.Pupil_Name
    End If

    Not sure whay it is doing this as it should ignore the instructions unless the If requirement is met shouldn't it??

    Thanks,
    ChrisOfCatford

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Why not hit the table/query the subform is based on with say ... DCount?
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    try :
    if isNull(me.SubForm.Form.FieldName)
    replace SubForm with your SubForm containers' name and FieldName with any fieldname from your subform

  6. #6
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    you might as well try
    me.SubForm.Form.Recordset.RecordsetCount
    should deliver to you a number how many records your subform contains

  7. #7
    Join Date
    Sep 2004
    Posts
    63
    M Owen,

    Thankyou very much, problem solved!

    Bachatero,

    Recordset.RecordsetCount doesn't seem to work at my end. Property not supported.

    Thanks anyway, much appreciated.

    Enjoy the weekend,
    ChrisOfCatford

  8. #8
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Quote Originally Posted by ChrisOfCatford


    Recordset.RecordsetCount doesn't seem to work at my end. Property not supported.
    Just for reference, Recordset.RecordCount would work. There is no RecordSetCount
    Inspiration Through Fermentation

  9. #9
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    ya .. i know was just too quick with my reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •