Problem with data type mismatch - error 80040e07

D

Dave Lagergren

I get the following error when trying to get records from a database:

Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.
/logon/Repair/editor/process_updates.asp, line 28

Line 28 is:
objRS.Open "Select * from Results WHERE PTN =" & SearchText, objConn, 0, 1

Here is the entire block of code:
<%
Dim SearchText, strKey, marker
' We have the PTN's stored in PTN1 - PTN10 on the input page
marker=1
strKey=0

DO While marker<11 ' We only want to do 10 iterations since we only
entered in up to 10 PTN's
SearchText = (Request("PTN" & marker ))

if SearchText < "1" then ' If the input is null then increment i and try
the next input
marker=marker+1
else ' Otherwise open the file and read all the records that match our PTN

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "Select * from Results WHERE PTN =" & SearchText, objConn, 0, 1

' Read in the records
DO While NOT objRS.EOF
Key = objRS("Key")
ContactNumber = objRS("ContactNumber")
Customer = objRS("Customer")
AgentIn = objRS("AgentIn")
Problem = objRS("Problem")
ProblemNotes = objRS("ProblemNotes")
AgentOut = objRS("AgentOut")
MSN = objRS("MSN")
MSN = objRS("SIM")
IMEI = objRS("IMEI")
PTN = objRS("PTN")
NewMSN = objRS("NewMSN")
NewSIM = objRS("NewSIM")
NewIMEI = objRS("NewIMEI")
' We don't want to input Location because we want to use the new
Location assigned in multi_edit.asp
' Location = objRS("Location")
Coverage = objRS("Coverage")
Tech = objRS("Tech")
PhoneUser = objRS("PhoneUser")
ServicePerformed = objRS("ServicePerformed")
ModelHandset = objRS("ModelHandset")
NewPhoneModel = objRS("NewPhoneModel")
TechNotes = objRS("TechNotes")
BAN = objRS("BAN")
LoanerNumber = objRS("LoanerNumber")
Accessories = objRS("Accessories")
AdvExchange = objRS("AdvExchange")
AdvanceExchangeRep = objRS("AdvanceExchangeRep")

if Key > strKey then ' We need to find the largest Key for this PTN
strKey= Key
end if

objRS.MoveNext


Loop
objRS.Close
Set objRS = Nothing
OBJConn.Close
Set OBJConn = Nothing
marker=marker+1
end if
loop

' the routine to save the new record goes here

%>

I use the same basic routine with another column (Key instead of PTN) for a
different search and it works fine.
 
S

Stefan B Rusynko

PTN1-PTN10 is a text string: SearchText = (Request("PTN" & marker ))
- so you need to close the string (w/ single quotes)

strSQL = "Select * from Results WHERE PTN ='" & SearchText & "'"
objRS.Open strSQL, objConn, 0, 1

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I get the following error when trying to get records from a database:
|
| Microsoft JET Database Engine error '80040e07'
| Data type mismatch in criteria expression.
| /logon/Repair/editor/process_updates.asp, line 28
|
| Line 28 is:
| objRS.Open "Select * from Results WHERE PTN =" & SearchText, objConn, 0, 1
|
| Here is the entire block of code:
| <%
| Dim SearchText, strKey, marker
| ' We have the PTN's stored in PTN1 - PTN10 on the input page
| marker=1
| strKey=0
|
| DO While marker<11 ' We only want to do 10 iterations since we only
| entered in up to 10 PTN's
| SearchText = (Request("PTN" & marker ))
|
| if SearchText < "1" then ' If the input is null then increment i and try
| the next input
| marker=marker+1
| else ' Otherwise open the file and read all the records that match our PTN
|
| Set objRS = Server.CreateObject("ADODB.Recordset")
| objRS.Open "Select * from Results WHERE PTN =" & SearchText, objConn, 0, 1
|
| ' Read in the records
| DO While NOT objRS.EOF
| Key = objRS("Key")
| ContactNumber = objRS("ContactNumber")
| Customer = objRS("Customer")
| AgentIn = objRS("AgentIn")
| Problem = objRS("Problem")
| ProblemNotes = objRS("ProblemNotes")
| AgentOut = objRS("AgentOut")
| MSN = objRS("MSN")
| MSN = objRS("SIM")
| IMEI = objRS("IMEI")
| PTN = objRS("PTN")
| NewMSN = objRS("NewMSN")
| NewSIM = objRS("NewSIM")
| NewIMEI = objRS("NewIMEI")
| ' We don't want to input Location because we want to use the new
| Location assigned in multi_edit.asp
| ' Location = objRS("Location")
| Coverage = objRS("Coverage")
| Tech = objRS("Tech")
| PhoneUser = objRS("PhoneUser")
| ServicePerformed = objRS("ServicePerformed")
| ModelHandset = objRS("ModelHandset")
| NewPhoneModel = objRS("NewPhoneModel")
| TechNotes = objRS("TechNotes")
| BAN = objRS("BAN")
| LoanerNumber = objRS("LoanerNumber")
| Accessories = objRS("Accessories")
| AdvExchange = objRS("AdvExchange")
| AdvanceExchangeRep = objRS("AdvanceExchangeRep")
|
| if Key > strKey then ' We need to find the largest Key for this PTN
| strKey= Key
| end if
|
| objRS.MoveNext
|
|
| Loop
| objRS.Close
| Set objRS = Nothing
| OBJConn.Close
| Set OBJConn = Nothing
| marker=marker+1
| end if
| loop
|
| ' the routine to save the new record goes here
|
| %>
|
| I use the same basic routine with another column (Key instead of PTN) for a
| different search and it works fine.
|
| --
| Dave Lagergren
| Manager - Data Applications
| Wireless Management, Inc
| Specializing in cellular wireless applications
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top