Solved

Searching for record

Posted on 2002-06-19
4
147 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
VBA Shell can't Find Word document 11 94
Protecting vb6 & .Net code Obfuscation 18 125
Problem to With line 4 57
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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