Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Searching for record

Posted on 2002-06-19
4
148 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
ID: 7092339
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
ID: 7092384
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
ID: 7094610
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
ID: 7094613
i know why already.. i should not bind the PolicyNo textbox to the dbase.. Just find out..Sorry
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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