criteria problems

  • Thread starter Thread starter TK
  • Start date Start date
T

TK

I have a form open through a command button with a criteria set. I recently
changed a few form names to more proper form names, I have made what I can
see is the nessary changes to any code or property that might refer to the
old form names.

The problem now is that when I click on the open form button I get a message
saying that the open form action was canceled. When I remove the criteria
code the form will open but will not be filtered, I need to filter to be
working.

Here is my code:
Private Sub cmdWorkOrder_Click()
On Error GoTo Err_cmdWorkOrder_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmWorkOrders"
stLinkCriteria = "[InspectionNo]=" & "'" & Me![txtInspectionNo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdWorkOrder_Click:
Exit Sub

Err_cmdWorkOrder_Click:
MsgBox Err.Description
Resume Exit_cmdWorkOrder_Click

End Sub
 
TK,

Is [InspectionNo] text or numberic? Your code indicates it
is defined as text. Check you data types defined in the
table.

In the test dB I created, I was able to get the "Open
Form Action was Canceled" by defining the data type as
number (integer) and using your code to compare for a text
string.

If [InspectionNo] (as defined in the table)is numeric,
change the criteria to:

stLinkCriteria = "[InspectionNo]=" & Me![txtInspectionNo]

If [InspectionNo] is supposed to be a string, change the
data type to text and leave the criteria as is.

HTH

Steve
 
Back
Top