Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,331 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,123 people online right now. Registration is fast and FREE... Join Now!




listview functions

 
Reply to this topicStart new topic

listview functions

emkaye
post 17 Feb, 2008 - 05:22 PM
Post #1


D.I.C Head

**
Joined: 12 Aug, 2007
Posts: 53


My Contributions


Hi please help me with list view functions. I also have my database. I have to pull the records out of the database and show it in the list view. I’ve already done that part. Now, here’s the scenario-I’m going to click an item or a row in the list view. The records in the list view will then be showed on the textboxes.
But the problem is an error occurred when I clicked one row in the list view. Here is the error:

Run-time error ’-2147217913 (80040e07)’;
Data type mismatch in criteria expression.

Below is my code:

CODE

Private Sub lvTariff_Click()
Dim SelectAPTariff As String
‘ClickAPTariff is a recordset

SelectAPTariff = "select * from TariffAP where FL_NO= '" & lvTariff.SelectedItem.Text & "' "
Set ClickAPTariff = myConn.Execute(SelectAPTariff)

If ClickAPTariff.EOF = False Then

txtFlightNo.Text = ClickAPTariff("FL_NO")
ClickAPTariff.MoveNext
End If

End Sub



where Set ClickAPTariff = myConn.Execute(SelectAPTariff) is highlighted when I tried to debug it.
User is offlineProfile CardPM

Go to the top of the page

Nayana
post 17 Feb, 2008 - 05:41 PM
Post #2


DIC Hawk - 나야나 नयन:

Group Icon
Joined: 14 Nov, 2007
Posts: 824



Thanked 5 times

Dream Kudos: 175
My Contributions


It's probably because the field FL_NO is a number.

Try this instead:
CODE

SelectAPTariff = "select * from TariffAP where FL_NO=" & Str(Val(lvTariff.SelectedItem.Text))

Here, the Val(...) turns a string into a number. The Str(...) turns a number into a string. The Str(...) function is unneccessary, but it just makes it explicit that the number is being turned into a string.

The Val(...) is necessary, because it prevents a non-number being entered into the query.
User is offlineProfile CardPM

Go to the top of the page

emkaye
post 23 Feb, 2008 - 02:52 AM
Post #3


D.I.C Head

**
Joined: 12 Aug, 2007
Posts: 53


My Contributions


thanks for the help. it worked.

smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 03:06AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month