Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
I am using an access database. I am trying to read my primary key, field name - intCustomerID, Data Type - AutoNumber. I am retrieving it into a form to send to the next page.

Here is the code that should work:


Response.write &quot;<form method='post' ACTION='buttonchoice.asp'>&quot;

while not objRec.EOF
Response.Write &quot;<tr><center>&quot;
Response.write &quot;<td><center>&quot; %>

<% Dim databaseid, id, intCustomerID %>
* <% id = CInt(objRS(&quot;intCustomerID&quot;)) %>
<% databaseid = id %>
<input type='radio' name='customer' value= '<%=databaseid%>'<%Response.write(&quot; checked&quot;)%>></td>

I keep crashing on the line marked with *, getting an error:


Microsoft VBScript runtime error '800a000d'
Type mismatch

I have tried all kinds of other lines such as:

<% id = objRS( &quot;intCustomerID&quot;) %>
<% id = objRS( intCustomerID) %>
<% id = CInt(objRS(&quot;intCustomerID&quot;)) %>
<% id = cstr(objRS(&quot;intCustomerID&quot;)) %>

No matter what I use, i get the Type Mismatch error.
Does anybody know why?

Thank you
thunderain
 
Hi

A few things spring to my usually empty mind ...

1) You are looping whilst not objRec.EOF - I am assuming this is a typo and you mean objRS.EOF

2) DONT &quot;dim&quot; your variables there! If the recordset loops around again it will error because it really doesn't like to declare the same varible multiple time. Move this line above your loop - if neccessary

3) You don't need to &quot;Cint&quot; your value, as it will become a variant type variable, so it can still be read as a number, and as you are not performing any obvious calculations to multiple decimal places - not required.

4) Cut to the chase! Strip down your code to a more manageable and efficient code -you never know when it will become important

Code:
  <% Dim databaseid, id, intCustomerID %>
* <% id =  CInt(objRS(&quot;intCustomerID&quot;)) %>
  <% databaseid = id %>
  <input type='radio' name='customer' value= '<%=databaseid%>'<%Response.write(&quot; checked&quot;)%>></td>

becomes

Code:
<input type='radio' name='customer' value='<%=objRS(&quot;intCustomerID&quot;)%>' checked></td>

See what you get from those pointers Derren
[The only person in the world to like Word]
 
Before doing anything else, put a
<% Option Explicit %>
at the top of the script after the LANGUAGE directive so that you will get an error for misspelled variable names. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top