|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > comparing a value on a form with a value on a subform |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|