J
JR
Hello,
I am attempting to use the like operator to determine if a
customer name (or a portion of name) exists in a table.
The user enters the name on a form in a text box then
presses a button. For some reason I can get the code to
work in a query but am unable to get the VBA code to
reconize the command (does not see similar named customer).
Any help would be appreciated.
'now determine if customer already exists
stSQL = "SELECT COUNT(*) AS AvailableRecords " & _
"FROM [dbo_tblCustomer] " & _
"WHERE ((dbo_tblCustomer.CustomerName)
Like """ & txtCustomerName & "*"");"
MsgBox stSQL
'create the connection to the current application and
Access database
Set con = Application.CurrentProject.Connection
'create a current record set from the above sql
statement
Set rst = CreateObject("ADODB.Recordset")
'open the record set using the sql statement
rst.Open stSQL, con, adOpenForwardOnly,
adLockReadOnly, adCmdText
MsgBox (rst!availablerecords)
I am attempting to use the like operator to determine if a
customer name (or a portion of name) exists in a table.
The user enters the name on a form in a text box then
presses a button. For some reason I can get the code to
work in a query but am unable to get the VBA code to
reconize the command (does not see similar named customer).
Any help would be appreciated.
'now determine if customer already exists
stSQL = "SELECT COUNT(*) AS AvailableRecords " & _
"FROM [dbo_tblCustomer] " & _
"WHERE ((dbo_tblCustomer.CustomerName)
Like """ & txtCustomerName & "*"");"
MsgBox stSQL
'create the connection to the current application and
Access database
Set con = Application.CurrentProject.Connection
'create a current record set from the above sql
statement
Set rst = CreateObject("ADODB.Recordset")
'open the record set using the sql statement
rst.Open stSQL, con, adOpenForwardOnly,
adLockReadOnly, adCmdText
MsgBox (rst!availablerecords)