Solved

Searching for record

Posted on 2002-06-19
4
144 Views
Last Modified: 2010-05-02
I have about 10 to 15 textbox controls that are bind to a datasource called data1
(Data1 is a data control). The textbox controls have their own datafields.
There is also a combo box which is fill with PolicyNo(one of the fields from the database)
When i choose one of the PolicyNo from the combo box, it should move to the record
that i want and update the other textboxes.
I tried using the Data1.Recordset.Move n, start
But how do i know the index of the record that i am currently in?????
0
Comment
Question by:laukhengsiong
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Mahdi Mansour earned 20 total points
Comment Utility
you can know the record u r in by doing a select ......
try:

data1.recourdsource="select * from TableName where PolicyNo = " & combo.text & " ; "
data1.refresh

...
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
You should use the FindFirst method:

Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "PolicyNo = '" & Combo1.Text & "'"
If Data1.Recordset.NoMatch Then
  Msgbox "Couldn't Find " & Combo1.Text
End If

Where PolicyNo is the field name in the recordset to look in and the policy number to match is a string value. If it is a numeric field then remove the ' characters as they are no longer required.
0
 

Author Comment

by:laukhengsiong
Comment Utility
the comment by kasanova works. BUT after using the refresh method, the combo box which bind to the field PolicyNo in the dbase becomes ""(EMPTY). i did not use the SELECT * to select all fields cos the function will not work so I select individual fields that i want and IT works!. Any idea why the combo box becomes empty???? Thanx
0
 

Author Comment

by:laukhengsiong
Comment Utility
i know why already.. i should not bind the PolicyNo textbox to the dbase.. Just find out..Sorry
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now