4 Replies - 2183 Views - Last Post: 19 November 2009 - 04:22 AM Rate Topic: -----

#1 raycomp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 25-August 09

Need help: Runtime error VB6

Posted 18 November 2009 - 11:59 AM

Ive got an Access Table called PurchaseOrder with fields ID1 (datatype AutoNumber) and Quantity (datatype Number)

On the form there are Textboxes named txtData(18) and txtData(17).

txtData(18).text = "3" and txtData(17).text = "16"

I need to update the value in table PurchaseOrder field Quantity to 3 where field ID1 = 16

I'm getting error message: Runtime error - 2147217913 (80040e7): Data type mismatch in citeria

when using the following code:

 dbcn.BeginTrans
	dbcn.Execute "UPDATE PurchaseOrder SET Quantity = '" & txtData(18).Text & "' WHERE ID1 = '" & txtData(17).Text & "'"
 dbcn.CommitTrans 


I have tried different ways to no avail.

Please help

Is This A Good Question/Topic? 0
  • +

Replies To: Need help: Runtime error VB6

#2 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,281
  • Joined: 25-March 09

Re: Need help: Runtime error VB6

Posted 18 November 2009 - 04:10 PM

do you try Cint() function on your textboxes. still check what values your tables have.
Was This Post Helpful? 1
  • +
  • -

#3 theunborncoder   User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 123
  • Joined: 15-October 09

Re: Need help: Runtime error VB6

Posted 18 November 2009 - 09:29 PM

number in database you can compare directly no need of single quotes

 dbcn.BeginTrans
	dbcn.Execute "UPDATE PurchaseOrder SET Quantity = " & cInt(txtData(18).Text) & " WHERE ID1 = " & txtData(17).Text 
 dbcn.CommitTrans 

[/quote]

try without single quotes.... it should work
Was This Post Helpful? 0
  • +
  • -

#4 Nash29   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 17-November 09

Re: Need help: Runtime error VB6

Posted 19 November 2009 - 03:49 AM

View Postraycomp, on 18 Nov, 2009 - 10:59 AM, said:

Ive got an Access Table called PurchaseOrder with fields ID1 (datatype AutoNumber) and Quantity (datatype Number)

On the form there are Textboxes named txtData(18) and txtData(17).

txtData(18).text = "3" and txtData(17).text = "16"

I need to update the value in table PurchaseOrder field Quantity to 3 where field ID1 = 16

I'm getting error message: Runtime error - 2147217913 (80040e7): Data type mismatch in citeria

when using the following code:

 dbcn.BeginTrans
	dbcn.Execute "UPDATE PurchaseOrder SET Quantity = '" & txtData(18).Text & "' WHERE ID1 = '" & txtData(17).Text & "'"
 dbcn.CommitTrans 


I have tried different ways to no avail.

Please help


Data Mismatch usually occurs when you try assigning a data to a field which is of another type. Here, the error is in criteria that means in WHERE clause.

You've been trying to check ID1 = '16'. It should be ID1 = 16.
Since ID1 is of Autonumber type (And Not a String), its generating an error.

theunborncoder is correct. You are using quotes with numeric values. Avoid quotes. Some numeric types might accept the numbers with quotes by implicitly converting them into their types but not all can do the same, since all have different size ranges. Use quotes only when dealing with strings or dates or similar types.

Cheers ?? :D
Was This Post Helpful? 1
  • +
  • -

#5 raycomp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 25-August 09

Re: Need help: Runtime error VB6

Posted 19 November 2009 - 04:22 AM

Thank u all for the very useful info. It is good to know that people visiting this site is always willing to help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1