PC Review


Reply
Thread Tools Rate Thread

How to seek and then reference the found record to a form record?

 
 
=?Utf-8?B?TWFj?=
Guest
Posts: n/a
 
      13th Mar 2007
I am having trouble using seek to find a record with a unique Serial Number
and then display that record on a form. The Serial Number input is a string
(textbox). My seek code works Ok but after seek, if not EOF, I try to find
absolute position and then use "goto" that record on the form but the
absoluteposition is not always correct. The record that gets shown is always
offset of one or two records from what I need.

Any help is appreciated.
--
Regards, Michael
 
Reply With Quote
 
 
 
 
strive4peace
Guest
Posts: n/a
 
      13th Mar 2007
FindRecord
---


Hi Michael,

try this:

Make one or more unbound combos on your form. Let the first column be
invisible and be the primary key ID of the recordsource of your form and
then, on its AfterUpdate event, launch the code to Find the record

so, if you want to display Serial Number but your (autonumber) primary
key is called SomeID...

RowSource -->
SELECT SomeID, [Serial Number]
FROM tablename
ORDER BY [Serial Number]

ColumnCount --> 2
ColumnWidths --> 0;2
ListWidth --> 2

AfterUpdate -->
=FindRecord()

this code goes behind the form:

'~~~~~~~~~~~~~~~~~~~~
Private Function FindRecord()

'if nothing is picked in the active control, exit
If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

'declare a variable to hold the primary key value to look up
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = Me.ActiveControl

'clear the choice to find
Me.ActiveControl = Null

'find the first value that matches
Me.RecordsetClone.FindFirst "SomeID = " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Function

'~~~~~~~~~~~~~~~~~~~~
where
SomeID is the Name of the primary key field, which is in the
RecordSource of the form -- I am assuming your primary key is a Long
Integer data type (autonumbers are long integers)

Warm Regards,
Crystal
*
(: have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Mac wrote:
> I am having trouble using seek to find a record with a unique Serial Number
> and then display that record on a form. The Serial Number input is a string
> (textbox). My seek code works Ok but after seek, if not EOF, I try to find
> absolute position and then use "goto" that record on the form but the
> absoluteposition is not always correct. The record that gets shown is always
> offset of one or two records from what I need.
>
> Any help is appreciated.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Goal Seek with dynamic Goal Seek Dkline Microsoft Excel Programming 1 18th Feb 2008 11:00 AM
Show record on form, bookmark for record was found using seek? =?Utf-8?B?TWFj?= Microsoft Access 8 15th Mar 2007 04:17 AM
Seek Seek spyware on registry Susan Windows XP General 6 8th Feb 2004 03:12 PM
BinaryWriter.Seek() vs BinaryWriter.BaseStream.Seek() Daniel Goldman Microsoft Dot NET Framework 6 30th Aug 2003 08:26 PM
Use bw.Seek or bw.BaseStream.Seek ? Daniel Goldman Microsoft C# .NET 0 23rd Aug 2003 04:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:39 AM.