TextBox Problem continues

Trinb37

Registered User.
Local time
Today, 08:11
Joined
Oct 9, 2003
Messages
23
Hi,
Its me again. After looking far and wide, I came up with this code:
Private Sub Command2_Click()
Dim Conn As Connection
Dim rst As Recordset
Dim strSQL As String
Set Conn = Text0.Value
strSQL = "SELECT FirstName, LastName FROM Employees WHERE EmployeeID " & "' & EmployeeID & '"
rst.Open strSQL, Conn
If Not rst.EOF Then
Text0.Value = rst.Fields("FirstName") & " " & rst.Fields("LastName")
End If
'Me.Text0 = Me.Text0 & " This is just a text." & vbCrLf
End Sub

But I am having great difficulty to get this code to work. The error message I keep receiving saids, 'Object required'. Can anyone help me write this code so that it will work well.
Thank you in advance for your help.:confused:
James
 
It appears to me that you are using EmployeeID as variable but it is not Dimmed in the code. Are you pulling the EmployeeID value from the table?

If you changed it to read:

Private Sub Command2_Click()
Dim Conn As Connection
Dim rst As Recordset
Dim strSQL As String
Dim EID as String

EID = me.EmployeeID

Set Conn = Text0.Value
strSQL = "SELECT FirstName, LastName FROM Employees WHERE EmployeeID " & "' & EID & '"
rst.Open strSQL, Conn
If Not rst.EOF Then
Text0.Value = rst.Fields("FirstName") & " " & rst.Fields("LastName")
End If
'Me.Text0 = Me.Text0 & " This is just a text." & vbCrLf
End Sub

What are you trying to actually do with this code?

GumbyD
 

Users who are viewing this thread

Back
Top Bottom