Hi
I have a problem on one form which I cannot fathom. When I hit the OK button I get an error message saying "Invalid use of null" but I cannot see where I am referring to a null.
There is quite a lot of code on the button but the starting bit (which is where my hunch is the problem lies since the error comes up instantly) is
There is more which I could post if anyone is interested.
Intriguingly if I cancel the error message, switch to design view, then switch straight back to form view and hit the button it runs perfectly.
I feel sure this says a lot to someone who knows what it is saying!
Any help greatly appreciated
Best wishes
I have a problem on one form which I cannot fathom. When I hit the OK button I get an error message saying "Invalid use of null" but I cannot see where I am referring to a null.
There is quite a lot of code on the button but the starting bit (which is where my hunch is the problem lies since the error comes up instantly) is
Code:
' Data identification for MP Christmas movements
Dim lngPat As Long
Dim intStartDay As Integer
Dim dtmEndDate As Date
Dim lngDrug As Long
Dim lngDose As Long
Dim lngCntId As Long
Dim strScript As String
Dim dtmStartDate As Date
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim stDocName As String
Dim stLinkCriteria As String
If Me.TCntDispPatt = 0 Then
MsgBox "You must enter a dispensing pattern for the script.", vbOKOnly, "Required Data"
Me.TCntDispPatt.SetFocus
Exit Sub
End If
' Populate variables for MP Christmas movements
lngPat = DLookup("TCntDispPatt", "tblTmpScriptContents")
intStartDay = DLookup("TCntStartDay", "tblTmpScriptContents")
dtmEndDate = DLookup("TCntEndDate", "tblTmpScriptContents")
lngDrug = DLookup("TCntDrug", "tblTmpScriptContents")
lngDose = DLookup("TCntDoseId", "tblTmpScriptContents")
strScript = DLookup("TCntScrNo", "tblTmpScriptContents")
lngCntId = DLookup("TcntId", "tblTmpScriptContents")
dtmStartDate = DLookup("TCntStartDate", "tblTmpScriptContents")
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Intriguingly if I cancel the error message, switch to design view, then switch straight back to form view and hit the button it runs perfectly.
I feel sure this says a lot to someone who knows what it is saying!
Any help greatly appreciated
Best wishes