3 Replies - 3102 Views - Last Post: 20 August 2012 - 08:26 AM Rate Topic: -----

#1 djaraojo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 20-July 12

Run Time Error -2147217900 (80040e14)

Posted 20 August 2012 - 12:21 AM

Well, I have look over the internet about this and maybe Im just so noob that I really cant get it right.

Here's my code

Public Function konek(k As String) As ADODB.Recordset
Dim con As New ADODB.Connection
con.Provider = "Microsoft.ACE.OLEDB.12.0"
con.ConnectionString = App.Path + "\dbBasketball2.accdb"
con.Open

Set konek = New ADODB.Recordset
konek.LockType = adLockOptimistic
konek.CursorType = adOpenKeyset
konek.Open k, con, adLockOptimistic
End Function

Private Sub Form_Load()
Set rs = konek("select * from tblPlayerstats where SeasonID = '" & fhcontrol.Label6.Caption & "' and GameID = '" & fhcontrol.Label5.Caption & "' and TeamID = '" & fhcontrol.Label4.Caption & "' and Active = '" & fhcontrol.lblactive1.Caption & "' and Order = '" & fhcontrol.lblorder1.Caption & "' ")

Label41.Caption = rs!Fname

Set rs = Nothing
End Sub



The error says:

Run-time error '-2147217900 (80040e14):

Syntax error (missing operator) in query expression 'SeasonID =
'seasonid' and GameID = 'Game001' and TeamID = 'Team001' and Active = '1' and '.


Thats it, and I cant see where or what is the problem,

Or... My database just sucks? really not good at normalizing either :(

Is This A Good Question/Topic? 0
  • +

Replies To: Run Time Error -2147217900 (80040e14)

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: Run Time Error -2147217900 (80040e14)

Posted 20 August 2012 - 04:22 AM

The one thing I always do, is assign the query to a string.

Put a breakpoint in your code once it's been assigned then print it to your immediate window at the breakpoint.

That way, you can get a true visualisation of your query and can sanity check it looks right.

Give it a go and if you're still struggling spotting the issue, post the output of the string print here.

If you do spot the problem, don't forget to post your findings too, as it may be useful for someone else in future.

This post has been edited by maj3091: 20 August 2012 - 04:23 AM

Was This Post Helpful? 0
  • +
  • -

#3 djaraojo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 20-July 12

Re: Run Time Error -2147217900 (80040e14)

Posted 20 August 2012 - 05:22 AM

breakpoint? where? how? and assign the query to string? O.o sorry im not familiar with that... :(
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: Run Time Error -2147217900 (80040e14)

Posted 20 August 2012 - 08:26 AM

You're already assigning it to a string in your Konect function.

Have a look at the variable k.

A suggestion for you, being a noob, have a look at using a naming convention, which will make your code easier to read.

A variable called "k", means nothing to anybody just glancing at your code, whereas a variable "strQuery", would be picked up as data-type String and it holds a query.

Google it, it well help you in future.

Breakpoints are set from the Debug menu or clicking in the left hand side of the code window. You can learn more from the help system of VB, or by googling.

This post has been edited by maj3091: 20 August 2012 - 08:27 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1