A
Al
I am getting a run-time error '2001': You canceled the previous operation.
it breaks on :
varValue = DLookup(FieldName, TableName, G_Field_Name_CD1 = G_Field_Name_CD1
And G_Field_Name_CD2 = G_Field_Name_CD2)
*****************
the above lookup is a part of a function and all the arguments have value
that shows when I place the curser over each one. I did not find any help on
this message and I do not understand what is causing it. I have this function
that fires on the onExit event It works with all the forms fine except one
form only and I can not see the difference. any help?
thanks
Just in case, here is the function:
*************************************************
Private Function DoubleEntryCompare(frm As Form, TableName As String,
FieldName As String, _
fld, G_Field_Name_CD1, G_Field_Name_CD2, TheValue As String) As Variant
Dim blTemp As Variant, varValue As Variant, intResponse As Integer
Dim db As Database, rst As Recordset, sql As String
Set db = CurrentDb()
If TableName = "qryfrmHealthHistory_1CPatient1" Then
TableName = Mid(TableName, 1, 29)
Else
TableName = Replace(TableName, "1", "")
End If
If Right(TableName, 17) = "qryfrmDemographic" Then
varValue = DLookup(FieldName, TableName, G_Field_Name_CD1 =
G_Field_Name_CD1)
Else
varValue = Nz(DLookup(FieldName, TableName, G_Field_Name_CD1 =
G_Field_Name_CD1 And G_Field_Name_CD2 = G_Field_Name_CD2))
End If
If IsNull(varValue) And (TheValue) = "" Then
blTemp = True
Else
If varValue = TheValue Then
Else
intResponse = MsgBox("WARNING: non-matching record in < " &
FieldName & " > " & Chr(10) & _
"First Entry: " & varValue & Chr(10) & "Second Entry: " &
TheValue & Chr(10) & _
"Was the second entry correct?", vbYesNo, "Different Values!")
If intResponse = 7 Then 'No
fld = varValue
frm.Refresh
Else
'edit first record
If Right(TableName, 17) = "qryfrmDemographic" Then
sql = "SELECT [" & FieldName & "] FROM [" & TableName & "] WHERE [" &
G_Field_Name_CD1 & "] = [" & G_Field_Name_CD1 & "];"
Else
sql = "SELECT [" & FieldName & "] FROM [" & TableName & "] WHERE [" &
G_Field_Name_CD1 & "] = [" & G_Field_Name_CD1 & "] And [" & G_Field_Name_CD2
& "] = [" & G_Field_Name_CD2 & "];"
End If
Set rst = db.OpenRecordset(sql)
If Not rst.EOF Then
rst.MoveFirst
With rst
.Edit
rst(FieldName) = TheValue
.Update
End With
End If
MsgBox "First entry has been changed to: " & TheValue
rst.Close
db.Close
End If
End If
End If
End Function
*******************************************************
this function works with all controls on all forms except this form the form
Name is "SOPA-B" and the table behind is "tblSOPA-B", would the hyphen cause
this?
thanks
Al
it breaks on :
varValue = DLookup(FieldName, TableName, G_Field_Name_CD1 = G_Field_Name_CD1
And G_Field_Name_CD2 = G_Field_Name_CD2)
*****************
the above lookup is a part of a function and all the arguments have value
that shows when I place the curser over each one. I did not find any help on
this message and I do not understand what is causing it. I have this function
that fires on the onExit event It works with all the forms fine except one
form only and I can not see the difference. any help?
thanks
Just in case, here is the function:
*************************************************
Private Function DoubleEntryCompare(frm As Form, TableName As String,
FieldName As String, _
fld, G_Field_Name_CD1, G_Field_Name_CD2, TheValue As String) As Variant
Dim blTemp As Variant, varValue As Variant, intResponse As Integer
Dim db As Database, rst As Recordset, sql As String
Set db = CurrentDb()
If TableName = "qryfrmHealthHistory_1CPatient1" Then
TableName = Mid(TableName, 1, 29)
Else
TableName = Replace(TableName, "1", "")
End If
If Right(TableName, 17) = "qryfrmDemographic" Then
varValue = DLookup(FieldName, TableName, G_Field_Name_CD1 =
G_Field_Name_CD1)
Else
varValue = Nz(DLookup(FieldName, TableName, G_Field_Name_CD1 =
G_Field_Name_CD1 And G_Field_Name_CD2 = G_Field_Name_CD2))
End If
If IsNull(varValue) And (TheValue) = "" Then
blTemp = True
Else
If varValue = TheValue Then
Else
intResponse = MsgBox("WARNING: non-matching record in < " &
FieldName & " > " & Chr(10) & _
"First Entry: " & varValue & Chr(10) & "Second Entry: " &
TheValue & Chr(10) & _
"Was the second entry correct?", vbYesNo, "Different Values!")
If intResponse = 7 Then 'No
fld = varValue
frm.Refresh
Else
'edit first record
If Right(TableName, 17) = "qryfrmDemographic" Then
sql = "SELECT [" & FieldName & "] FROM [" & TableName & "] WHERE [" &
G_Field_Name_CD1 & "] = [" & G_Field_Name_CD1 & "];"
Else
sql = "SELECT [" & FieldName & "] FROM [" & TableName & "] WHERE [" &
G_Field_Name_CD1 & "] = [" & G_Field_Name_CD1 & "] And [" & G_Field_Name_CD2
& "] = [" & G_Field_Name_CD2 & "];"
End If
Set rst = db.OpenRecordset(sql)
If Not rst.EOF Then
rst.MoveFirst
With rst
.Edit
rst(FieldName) = TheValue
.Update
End With
End If
MsgBox "First entry has been changed to: " & TheValue
rst.Close
db.Close
End If
End If
End If
End Function
*******************************************************
this function works with all controls on all forms except this form the form
Name is "SOPA-B" and the table behind is "tblSOPA-B", would the hyphen cause
this?
thanks
Al