Below is some code I am working on to check an Access database for the presence of a part number, then prompting the user if they want to overwrite the record..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ExistingRecord As Boolean
Dim prmptuser As Long
' Open an ADO Connection
Dim adoCn As New ADODB.Connection()
adoCn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\Development\Databases\STNDCARDS.mdb"
' Open an ADO Recordset
Dim adoRs As New ADODB.Recordset()
adoRs.Open("SELECT * FROM tblTemp WHERE CATALOG_NO = & ' " S4-7445-AJ" ', adoCn)
With adoRs
If .RecordCount > 0 Then
ExistingRecord = True
Else
ExistingRecord = False
End If
If ExistingRecord = True Then
prmptuser = MsgBox("Record already exists"
Else
MsgBox("Not on File"
End If
End With
adoRs.Close()
adoCn.Close()
End Sub
As I have it now, i have the select statement finding a match for a specific number and the program tells me it is not on file. I copied the part number directly from the database, so i am baffled at that. I would like the WHERE criteria to be = textbox1.text. What do I have wrong and what is the proper syntax for what i need? Thanks in advance!!