Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Is This Code Correct?

$
0
0
What im Trying to do is This

a) The form shall prompt the user to enter LanID
b) Check the T_EMPLOYEE table to see if the LanID already exist

table field= LanID
form field=UserID


Private Sub Form_Load()

Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim rst3 As DAO.Recordset

' Set the variables to the current database in use and tables
Set db = CurrentDb()
Set rst = db.OpenRecordset("NRCEmployees")
Set rst1 = db.OpenRecordset("T_EMPLOYEE")
Set rst2 = db.OpenRecordset("T_EMPLOYEE_INFO")

Dim strMsg As String
Dim strLANID As String
Dim strSQL As String

strMsg = "Enter Employee's LanID"
strLANID = InputBox(Prompt:=strMsg)
Debug.Print strLANID
With rst1
strSQL = "Select * From rst1 where LanID = " & Me!UserID
Debug.Print strSQL
DoCmd****nSQL strSQL
If Not .NoMatch Then 'we found the record
MsgBox "We found the record"
!Me.UserID = LanID
End If
End With


rst.Close
rst1.Close
rst2.Close
End Sub




If not How Should i write The strSQL statement

Viewing all articles
Browse latest Browse all 13329

Trending Articles