Adodc1 find record

Hi,

Can someone review this code please, I'm not sure were it's gone wrong
While running the code Visual Basic 6, pops up with this message. Run-Time error "91"
object variable or with block  variable not set.

I am hoping I can enter the ID of the customer in a textbox which is named "mSearch.Text" and for it to pop up with the record found displaying the information in another form.

The data is supplied via Microsoft Access  using ODBC.

Private sub Button1_Click

Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "Customer_ID = '" & Trim(mSearch.Text) & "' "


If Adodc1.Recordset.EOF Then

     MsgBox "No Records Found... Try Again"
 
 Else
 
     MsgBox "Records Found"
     load fmcustomer_Details

 End If
end sub
TechLadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Usama FoadIT ManagerCommented:
1- Did you set the database name and table name correct?

2- Did you Open the connection?

3- Do you have field named "Customer_ID"?

4- Please give us the ODBC setting that you use.
TechLadAuthor Commented:
Checked all that and still the same
Cristi_ECommented:
Hi,
Can you pack (archive) your sample VB6 project along with your sample database and attach it here?

Cristi
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

TechLadAuthor Commented:
Sure, I've attached the project for you.
Project.zip
Cristi_ECommented:
Hi,
Check the attached archive. I've made some changes to your routine.

The routine now looks like this:


Cristi
Private Sub lblView_Click()
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DataBase\MJNComputers_DataBase.mdb;Persist Security Info=False"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "SELECT * FROM Customer_Table WHERE Customer_ID='" & Trim(mSearch.Text) & "' "
    Adodc1.Refresh
    
    If Adodc1.Recordset.EOF Then
    
         MsgBox "Sorry, The information supplied is incorrect."
    
     Else
    
         MsgBox "Customer Found"
         Load FmCustomer_Details
    
     End If
End Sub

Open in new window

Adodc1-find-record.zip

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TechLadAuthor Commented:
Thanks very much for your help and quick respsonse Cristi_E

It works perfectly :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.