Hi
How can i move to a particular record in a database when i select a data inside a combobox?
Thanks in advance!
Printable View
Hi
How can i move to a particular record in a database when i select a data inside a combobox?
Thanks in advance!
Hi!
After selecting the data in the combobox,
U can change the Criteria of your SQL query, using the combobox value.
Hope this is ur requirement.
smrenga
Check out the Bookmarks topic in Access help and RecordsetClone.
Basically you look up the bookmark of the item you have selected and then do a seek for that bookmark.
If u need more, I will check in later.
Cheers,
Paul.
P.S. Sorry I cannot give you the code - I just do not have time this a.m. I can do it later if you can wait.
Thanks for the reply guys
But does the Recordsetclone works in vb6?
By the way i am using a databound to connect to Access
You need to get at the recordset you are using for record display, use a find method to locate the record indicated in the Combo box and then use bookmarks to synchronise (The find method gives you access to the record but does not move the current position)
You need something like the following...
The Combo Box cannot be bound, of course, set its data up in Form_Load or similar.Code:Dim rst As Recordset
Dim vBmark As Variant
Dim strFind As String
Set rst = Me.Data1.Recordset
strFind = "Field='" & Trim$(Str(Me.Combo1.ItemData(ListIndex))) & "'"
'NB I cannot remember how to get the data back from the ComboBox - this a'int it!!!
'Do not include ' delimiters if the value is a number!
'Check the ListIndex is <> -1
rst.MoveFirst
rst.FindFirst (strFind)
If Not rst.NoMatch Then
vBmark = rst.Bookmark
Me.Data1.Recordset.Bookmark = vBmark
Else
MsgBox "Find failed!"
End If
Hope it helps.
Paul
P.S. There is no recordset clone but the Data1.Recordset has a clone property
P.P.S. Ensure you are bound to a snapshot or a dynaset (Not a table) or it will not work.
[Edited by paulw on 10-31-2000 at 09:04 AM]