User
is a reserved keyword in MS-Access. You need to put it between square brackets
Dim table As String = "SELECT UserID FROM [User] WHERE UserID = ...
Said that, your query has other problems. A better approach is this one:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim table As String = "SELECT UserID FROM User WHERE UserID = @uid"
Using conn = New OleDbConnection(.....)
Using da = New OleDbDataAdapter(table, conn )
da.SelectCommand.Parameters.Add("@uid", OleDbType.VarWChar).Value = textBox1.Text
ds = New DataSet
da.Fill(ds, "User")
If (ds.Tables("User").Rows.Count > 0) Then
Form2.Show()
End If
End Using
End Using
End Sub
I have changed your string concatenated query text to a parameterized query. This approach is more safe because it avoids Sql Injection and remove the need to escape properly your strings.
Also another very important advice that I feel to give is to avoid at all costs global variables to keep objects like a connection or an adapter around. This will give you a lot of trouble when something unexpected happens and your connection is leaved in unpredictable state.
Finally, if you just need to check if you have a UserID in your table, then there is no need to build an OleDbDataAdapter, a DataSet and fill it. You could just use ExecuteScalar method of the OleDbCommand
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim table As String = "SELECT UserID FROM User WHERE UserID = @uid"
Using conn = New OleDbConnection(.....)
Using cmd = New OleDbCommand(table, conn )
cmd.Parameters.Add("@uid", OleDbType.VarWChar).Value = textBox1.Text
conn.Open()
Dim result = cmd.ExecuteScalar()
if result IsNot Nothing then
Form2.Show()
End If
End Using
End Using
End Sub