troubleshooting Question

Data type mismatch in criteria expression using access and vb6

Avatar of awolarczuk
awolarczukFlag for Australia asked on
Programming Languages-OtherProgrammingVisual Basic Classic
17 Comments1 Solution631 ViewsLast Modified:
gday all,
WHen i try running my code i am getting a Data type mismatch in criteria expression here is the code below what i am trying to do is find out how many day there has been since a old date

Private Sub ListView1_Click()
Dim rs As New ADODB.Recordset
      Dim sql As String
        cnn1.Open
        sql = "select * from [client info] where [client id] = " & ListView1.SelectedItem.SubItems(2)
         rs.Open sql$, cnn1, adOpenDynamic, adLockPessimistic
     
    fname.Caption = rs.Fields("Title") & " " & rs.Fields("first name") & " " & rs.Fields("last name")
    clientID.Caption = rs.Fields("Client ID")
    address.Caption = fixnull(rs.Fields("address"))
    cityinfo.Caption = fixnull(rs.Fields("suburb") & " " & rs.Fields("state") & " " & rs.Fields("post code"))
    'Menu.DOB.Caption = fixnull(rs.Fields("DOB"))
    'Menu.SEX.Caption = fixnull(rs.Fields("sex"))
    phone.Caption = "Ph:" & "" & (rs.Fields("Phone"))
    molb.Caption = "Molb:" & "" & (rs.Fields("molb"))
    first.Caption = "Client Since" & " " & (rs.Fields("first visit"))
rs.Close
        sql = "select * from [visits] where [client id] = " & ListView1.SelectedItem.SubItems(2) & ""
              rs.Open sql, cnn1, adOpenDynamic, adLockPessimistic
              Label4.Caption = rs.Fields("last visit")
Label6.Caption = DateDiff("DDDD", CVDate(Label4.Caption), Date) - IIf(Format$(Date, "mmdd") < Format(Label7, "mmdd"), 1, 0)
rs.Close
cnn1.Close
    fname.Visible = True
    clientID.Visible = True
    address.Visible = True
    cityinfo.Visible = True
    phone.Visible = True
    molb.Visible = True
   
    ListView1.ListItems.Clear
    Picture1.Visible = False
    Picture2.Visible = True
    massageg.Visible = False
    noedit.Visible = False
    massagev.Visible = True
    first.Visible = True
    Label6.Visible = True
   
   
End Sub
ASKER CERTIFIED SOLUTION
Arthur_Wood

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros