Sub all()
        connection()
        Dim see = "Select * from info where Last Name = '" & txtLast.Text & "' and First Name = '" & txtFirst.Text & "'"
        dcom = New OleDbCommand(see, dcon)
        dcom.ExecuteScalar()

        If dcom.ExecuteScalar > 0 Then
            Dim gather = "Select * from info where Last Name = '" & txtLast.Text & "' and First Name = '" & txtFirst.Text & "'"
            dcom = New OleDbCommand(gather, dcon)
            dr = dcom.ExecuteReader
            dr.Read()

            If dr.HasRows Then

                Dim last = dr(1)
                Dim first = dr(2)

                MsgBox("The name" & last + first & "already exists!")


                dcon.Close()
            End If
        Else
            borrower()


        End If
    End Sub
  • Whenever I click the button for saving. it always says "Syntax error (missing operator) in query expression" What will I do? :|

Spaces in column names are the problem. If you are on SQL Server put them in brackets.

What do you mean by that? I'm only connecting it to MS Access. Can you explain further more. Sorry I'm just a newbie here. :)

Select * from info where [Last Name] ...

Even in "and First Name"? Should I put bracket?

Yes.

To avoid confusion it is better to remove the blanks or replace them with underscores as in LastName or Last_Name

Still the same man. No changes. The same error. Syntax error (missing operator) </3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.