i hv an interface sumthing like this. i/m using VB6 and i wanna find record in MS Access using find command button. firstly user will key in an employee number as a key to find that user record in MS Access. after that, the data will appear in the form above the search frame. im new with VB6'so i need some help.. thanks.. :)

Recommended Answers

All 5 Replies

You can do this ata database level using SQL queries.

if the employee number is a number use emp_number=number
if the employee number is a string use emp_number like '%string%'

Private Sub cmdfind_Click()
Dim a As String
Dim b As String


a = text1.text 'employee number
If Len(a) = 0 Then Exit Sub
b = "Employee Number Like """ & a & "*"""
Data1.Recordset.FindNext b
If Data1.Recordset.NoMatch Then
MsgBox "No record found", vbExclamation
end If
Exit Sub

when i put dis coding, there was an error.
Run-time error '3077'
Syntax error (missing operator) in expression.

when i debug, the error was at:
Data1.Recordset.FindNext b

please correct this

b = "Employee Number Like """ & a & "*"""

b = "Employee Number Like ' " & a & " ' "

this will help u i think

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.