IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Access
Search Access Group:

Advanced
-Collapse +Expand Access To/From
To/FromCODEGuides
-Collapse +Expand Access Store
PRESTWOODSTORE

Prestwood eMagazine

December Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyMicrosoft Access BoardAccess VBA Programming Topic   Print This     

Using VB to set the form's current record

Using VB to set the form's current record in Access VBA Programming topic (part of our Microsoft Access group).

Quick Search: form's   current   Using VB   Using VB set   form's current  
James Naylor
 (Inactive)
Lomita, CA, USA
I've developed an information tracking database, which uses an a AutoNumber field as the PrimaryKey. This number is used as a reference number.

What I'm trying to do is write a subroutine that moves to a record based on the reference number entered by the user, as the regular Find dialog defaults to the field with the focus.

I've managed to write code to build the RecordSet and Seek out the record, based on the number entered, but what I'm having a problem with is setting the form's record to the one found by the Seek method.

Anybody have any suggestions? All I need is a direction, one sentence reply would be sufficient....but if you do have some sample code, that would be great.

Thanx in advance, James
 Posted 20 years ago (Thread Starter)
Comment Quote
About James Naylor -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #804, 5 replies
Thread Started 1/31/2001 12:47:00 PM
View Counter=2372
Last Reply Posted 2/5/2001 8:04:00 AM)
Location=Lomita, CA, USA  
Joined=20 years ago   MB Posts=5  
James Naylor
 (Inactive)
Lomita, CA, USA
Thanx I will.

I did read about that, but I ignored it as I thought I read it doesn't work with the RecordSet object.

Thanx again.
 Posted 20 years ago (Thread Starter)
Comment Quote
About James Naylor -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #810 (Level 1.1)  Reply to 804
Thread Started 1/31/2001 4:14:00 PM
View Counter=2
Location=Lomita, CA, USA  
Joined=20 years ago   MB Posts=5  
James Naylor
 (Inactive)
Lomita, CA, USA
Thank you HTH.

If I remember correctly, the reason I couldn't use this method was that I don't believe the field to search could be specified in code. I think this method displays the Edit | Find dialog, which defaults to the field with the current focus.

However, if I'm wrong please correct me!
 Posted 20 years ago (Thread Starter)
Comment Quote
About James Naylor -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #876 (Level 1.2)  Reply to 804
Reply Posted 2/5/2001 7:56:00 AM
Location=Lomita, CA, USA  
Joined=20 years ago   MB Posts=5  
Most Recent Post
James Naylor
 (Inactive)
Lomita, CA, USA
Thank you Daniel for the Bookmak tip, it worked.

For anyone out there who has the same question, this was how I addressed the problem:

Private Sub Search_Task_Number_Click()
On Error GoTo Err_Search_Task_Number_Click

' // This routine pops up an InputBox and asks for the dev. tracking
' // number and then moves to that record.

Dim strMessage, strTitle, strDefault, scratch As String
Dim lngItemNum As Long
Dim Check

Check = True ' Initialize variables.

' Display message, title, and default value.
strMessage = "Enter task number" ' Set prompt.
strTitle = "Task Number Search" ' Set title.

Do ' Outer loop.
' Prompt for tracking number
scratch = InputBox(strMessage, strTitle)

' / Check for blank or cancel, it's the same value
If scratch = "" Then GoTo Exit_Search_Task_Number_Click

' // Convert string input to long integer for field type match
lngItemNum = Val(scratch)

' // Move to the first occurance to the tracking number in the forms'
' // record set
Me.RecordsetClone.findfirst "[DevelopmentTrackingNumber] Like " & lngItemNum

' // Check for no matching record
If Me.RecordsetClone.NoMatch Then
MsgBox "No entry found" ' No record found, so inform and prompt again
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
GoTo Exit_Search_Task_Number_Click ' Record found so leave
End If

Loop Until Check = False ' Exit outer loop immediately


Exit_Search_Task_Number_Click:
Exit Sub

Err_Search_Task_Number_Click:
MsgBox Err.Description
Resume Exit_Search_Task_Number_Click
End Sub
 Posted 20 years ago (Thread Starter)
Comment Quote
About James Naylor -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #878 (Level 1.3)  Reply to 804
Reply Posted 2/5/2001 8:04:00 AM
Location=Lomita, CA, USA  
Joined=20 years ago   MB Posts=5  
ScottCybak
 (Inactive)
Windsor, Ontario, Canada
Try DoCmd.FindRecord

This should let you jump to the appropriate record.

HTH
 Posted 20 years ago
Comment Quote
About ScottCybak -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #857 (Level 1.4)  Reply to 804
Reply Posted 2/4/2001 3:06:00 PM
Location=Windsor, Ontario, Canada  
Joined=20 years ago   MB Posts=64  
Daniel Fought
Prestwood IT
Home office in Fresno, CA.
Check out the bookmark property

Dan Fought
Senior Programmer Analyst
Prestwood IT Solutions
http://www.prestwood.com

 Posted 20 years ago
Comment Quote
About Daniel Fought -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Daniel Fought
Danial Fought is a senior programmer analyst with Prestwood IT where he develops custom Windows software and custom websites. When Dan is not coding for clients, he participates in this online community. Coding specialties include Paradox/ObjectPAL, MS Access, Visual Basic, and VS.Net/VB.Net.

Post ID #806 (Level 1.5)  Reply to 804
Reply Posted 1/31/2001 1:46:00 PM
Location=Home office in Fresno, CA. 
Joined=19 years ago   MB Posts=401   KB Posts=12   KB Comments=4  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P195A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #804 Counter
2372
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2021 Prestwood IT Solutions.   [Security & Privacy]