#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0

    comparing a value on a form with a value on a subform


    i believe the logic is right. when i hardcode val2 it works fine. i just need to know how to find out the number of records in the form so i can compare that value with another value on another form. the recordcount property is saying "object variable or with block variable not set" i have no idea why it is saying this. please help!


    Private Sub New_Communication_Yes_Click()
    On Error GoTo Err_New_Communication_Yes_Click
    Dim val1 As String, val2 As String
    Dim commsession As Recordset

    val1 = Form_Prospects.Restrictions.Value

    val2 = commsession.RecordCount

    If (val1 <= val2) Then
    MsgBox "Restricted"
    Else
    DoCmd.GoToRecord , , acNewRec
    Communication_Number.Value = CurrentRecord
    Communication_Date.Value = Format(Now, "mm dd yy")
    End If
    Exit_New_Communication_Yes_Click:
    Exit Sub

    Err_New_Communication_Yes_Click:
    MsgBox Err.Description
    Resume Exit_New_Communication_Yes_Click

    End Sub
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    1
    Rep Power
    0

    Thumbs up


    It's a little bit too late to answer but... for curious people.

    It looks like a VBA Access function. As the error message told you, the variable [commsession] must be set before being used to access object's properties.
    I suppose that you want to reference the recordset under a form called [Form_Prospects].
    So, yous must add a new code line between val1 and val2 affectations:

    Dim commsession As Recordset

    val1 = Form_Prospects.Restrictions.Value
    set commsession = Form_Prospects.Recordset
    val2 = commsession.RecordCount

    see you

IMN logo majestic logo threadwatch logo seochat tools logo