Hi,
Please guide me.
I have a table tblDepartment with below records;
DeptID Department
1001 Finance
1002 Mr.Bean's Office
1003 CEO's Office
1004 Bazza@Home
1005 HR
On a form a field is available as txtDepartment. Once I enter value in txtDepartment a query should show the DeptID. For this purpose I am using the below script;
The above script is showing an Error if the input (CEO's) is passed to this query. The error is;
Syntax Error(Missing Operator) in Query Expression ‘Department like ‘*CEO’s*’.
How I can manage the Sing quote in data?
Thanks
Ismail
Please guide me.
I have a table tblDepartment with below records;
DeptID Department
1001 Finance
1002 Mr.Bean's Office
1003 CEO's Office
1004 Bazza@Home
1005 HR
On a form a field is available as txtDepartment. Once I enter value in txtDepartment a query should show the DeptID. For this purpose I am using the below script;
Dim sqltxt As String
Dim rst As Recordset
Dim dept As Integer
sqltxt = "SELECT DepartmentID from tblDepartment where Department like '*" & Me.txtDepartment.Value & "*'"
Set rst = CurrentDb.OpenRecordset(sqltxt)
dept = rst!DepartmentID
Stop
End Sub
The above script is showing an Error if the input (CEO's) is passed to this query. The error is;
Syntax Error(Missing Operator) in Query Expression ‘Department like ‘*CEO’s*’.
How I can manage the Sing quote in data?
Thanks
Ismail