O
Orlando
Hi, I have a table (Departments) and 2 fields DeptCode (Key) and DeptName, I
have these fields in a Form and I also have a text box Text95, what I want to
do is to type the department code in the text95 and display the description,
later on I will display more information but for now I want to try just with
the description, I created a command button with the code bellow but when I
typed the code like "IT" and click the command buttom, open a message box
asking to include that information (IT), I am new in VBA but I have used
select instructions before and this never happened to me before, if someone
can help me I would appreciate it.
Thanks
Private Sub Command6_Click()
Dim Sql As String
Sql = "SELECT Departments.DeptCode, Departments.DeptName " & _
"FROM Departments WHERE DeptCode = " & [Forms]![AddDepartments]![Text95]
Forms!AddDepartments.RecordSource = Sql
End Sub
have these fields in a Form and I also have a text box Text95, what I want to
do is to type the department code in the text95 and display the description,
later on I will display more information but for now I want to try just with
the description, I created a command button with the code bellow but when I
typed the code like "IT" and click the command buttom, open a message box
asking to include that information (IT), I am new in VBA but I have used
select instructions before and this never happened to me before, if someone
can help me I would appreciate it.
Thanks
Private Sub Command6_Click()
Dim Sql As String
Sql = "SELECT Departments.DeptCode, Departments.DeptName " & _
"FROM Departments WHERE DeptCode = " & [Forms]![AddDepartments]![Text95]
Forms!AddDepartments.RecordSource = Sql
End Sub