I keep getting an error message Invalid Use of NULL when trying to select data from a list box on another form and then display the results in my main form.
This is my code on the search form...
The debugger highlights line
Form_frmInputData.Initialise Me.lstSearch
as the problem.
This is my code on the main form
Where have I gone wrong?
This is my code on the search form...
Code:
Private Sub lstSearch_DblClick(Cancel As Integer)
Call UnLockAll
If IsNull(Me.lstSearch) Then
MsgBox "Select from the list", vbExclamation
Exit Sub
End If
Form_frmInputData.Initialise Me.lstSearch
Form_frmSearchRecords.Visible = False
End Sub
The debugger highlights line
Form_frmInputData.Initialise Me.lstSearch
as the problem.
This is my code on the main form
Code:
Sub Initialise(strPatientRef As String)
Dim cnn As ADODB.Connection
Dim sQRY As String
'*************************************************************************************
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;User Id=Admin; " & _
"Data Source=" & cTables
'*************************************************************************************
DoCmd.SetWarnings False
Call UnLockAll
Me.cboGender.Enabled = True
Me.cboReferringAgent.Enabled = True
Me.cboReferralDestination.Enabled = True
Me.cboReasonNotAccepted.Enabled = True
Me.cboChangedDestination.Enabled = True
Me.cmdSubmit.Enabled = True
Me.cmdSearchRecords.Enabled = True
Me.cmdMainMenu.Enabled = True
sQRY = _
"SELECT PatientID, PatientRef, Forename, Surname, Name, Address1, Address2, Address3, " & _
"PostCode, DateOfBirth, Age, Gender, ReceivedDate, ReceivedTime, ReferringAgent, ReferralDestination, " & _
"Comments, ReasonNotAccepted, ChangedDestination, ChangedDestinationComments, ChangedInputBy, " & _
"ChangedInputDate, InputBy, InputDate, InputFlag " & _
"FROM tblICReferralRecord " & _
"WHERE PatientRef = '" & strPatientRef & "' "
Debug.Print sQRY
Me.RecordSource = sQRY
Me.txtPatientRef = IIf(IsNull(strPatientRef), "", (strPatientRef))
Me.txtDummy.SetFocus
Me.txtForename.Value = PCASE(Me.txtForename.Value)
Me.txtSurname.Value = PCASE(Me.txtSurname.Value)
cnn.Close
Set cnn = Nothing
End Sub
Where have I gone wrong?