Help ! Please - 'Object Required'

PhilipEwen

Registered User.
Local time
Today, 14:45
Joined
Jun 11, 2001
Messages
81
Hi,
I am trying to error trap. When someone gets presented with data on a client, they can click a date on the record and it opens a detailed form presenting them with all the data relevant to the date they clicked.
The PROBLEM is that if there is no data ( past history of the client ) i want to make it so that if the user clicks on the blank datasheet output, it comes up with a messgae saying 'There is no past data on the client'.

Here is my code:
Private Sub TreatmentDate_DblClick(Cancel As Integer)


On Error GoTo Err_TreatmentDate_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customer_Treatment_Detailed"
stLinkCriteria = "[TreatmentID]=" & Me![TreatmentID]

If Me![TreatmentID] Is Null Then
Dim strTitle As String
Dim strMessage As String
Dim lResponse As Long
strTitle = "No Treatment History"
strMessage = "There is no history for this Customer, please Add a History"
lResponse = MsgBox(strMessage, vbInformation + vbOKOnly, strTitle)
Cancel = True
Me.Undo

Else

DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_TreatmentDate_DblClick_:
Exit Sub

Err_TreatmentDate_DblClick:
MsgBox Err.Description
Resume Exit_TreatmentDate_DblClick_


End Sub

This should therefore check to see if the TreatmentID has no content, then display a message and exit. If there is a TreatmentID on the form, then it goes off and opens the detailed form.

I just get 'not object type' message.

I am new to VB ( day 2 ) so a full explanation would be really appreciated. ( or a better way of doing it !! )

Many thanks
 
Hi Philip,

you could try 'if IsNull(Me.[TreatmentID])'instead, but are you sure that the field is null? if it's a string it may be "" instead, in which case you need 'if Me.[TreatmentID]=""'. As an ID ( integer? ) field it could also be 0, in which case 'if Me.[TreatmentID]=0'

H some of TH,

Drew
 
Thanks for your help Drew BUT unfortunately none of this works.
Is there any way i can list variables whilst running so i can see the value of TreatmentID ??
 

Users who are viewing this thread

Back
Top Bottom