Question : Check if existing record in database?

Hi.  I am attempting to check whether a project name already exists in the database.  I am using SQL server 2005 as the database back end with MS Access being the front end.  The code is attached below, i am just curious where i am going wrong.  Your advice is appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Private Sub Command96_Click()
Dim db As DAO.Database      ' **** current database
Dim r As DAO.Recordset
Dim sSQL As String
Dim strCheck As String
Dim str1 As String
Dim str2 As String

Set db = DBEngine(0)(0)
strCheck = txtCheck.Value
MsgBox strCheck

sSQL = "SELECT "Project Name" from Projects WHERE ID = '" + strCheck + "'"

Set r = db.OpenRecordset(sSQL)

If r.EOF And r.BOF Then

Else
    str1 = r.Fields("Project Name").Value
End If
     
MsgBox str1

if str1 = strCheck
	msgbox "Project Name exists in database"
else
	msgbox "Generic Message to confirm it will go through"
end if

end sub

Answer : Check if existing record in database?

Are they perhaps included in some other container as well.  The included snipet works for me in VS2008
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GroupBox1.Visible = True
        GroupBox2.Visible = False
    End Sub

    Private Sub RadioButtonBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonBox1.CheckedChanged
        If RadioButtonBox1.Checked = True Then
            GroupBox1.Visible = True
            GroupBox2.Visible = False
        Else
            GroupBox1.Visible = False
            GroupBox2.Visible = True
        End If
    End Sub

    Private Sub RadioButtonBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonBox2.CheckedChanged
        If RadioButtonBox1.Checked = True Then
            GroupBox1.Visible = True
            GroupBox2.Visible = False
        Else
            GroupBox1.Visible = False
            GroupBox2.Visible = True
        End If
    End Sub
End Class
Random Solutions  
 
programming4us programming4us