Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 28th, 2004, 09:11 AM
Authorized User
Join Date: Oct 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Form control to browse records

I have looked high and low to figure this one out, and all I can think of is that it's so easy that nobody even has to ask about this. Of course I can't figure it out, and so here I ask:

How do you make a control on a form so you can CHOOSE the record that you view instead of just changing the value in the current record for that field? PLEASE someone has to know this. It seems like something that should be right in front of your face built in to Access.

Note that I am trying to select the record based on the primary key field, so there are no duplicates, and the field is indexed.

Thanks in advance!

  #2 (permalink)  
Old October 28th, 2004, 10:30 AM
Authorized User
Join Date: Oct 2004
Location: Austin, TX, USA.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts

The combo box wizard can build a combo box with code behind it to navigate to the record chosen in the combo - is that what you want to do? The code runs in the AfterUpdate event of the procedure to "move" to the new row. It gets a copy of the form's RecordsetClone, does a FindFirst on the key value, and if found, assigns the Bookmark of the recordset to the Bookmark of the form to move to that row.

John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
  #3 (permalink)  
Old October 29th, 2004, 09:26 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts


  If you use the combo box wizard to look for a record in your form, be sure to add an entry to the form's OnCurrent event to synchronize the record on your form with the combo box so that as you scroll through your records, your combo box follows along.

   Add this line to the form's On Current event:

   cboName = RecordID

   where cboName is the name of your combo box, and RecordID is the primary key field name of the records on your form. You need to place the pk on the form, but you can hide it by setting it's properties to Visible/No.

   I also use another method that involves a combo box and button to look up records on a form when I am using a SQL back end or a large Access database on a network in order to keep traffic down. But this wizard works well for most Access apps.

  #4 (permalink)  
Old October 29th, 2004, 10:22 AM
Authorized User
Join Date: Oct 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Hey thanks all! Between the two answers that works exactly as I need it to. I knew that lookup function was sometyhing that I was overlooking.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeater Control: No Records Found jumpseatnews ASP.NET 2.0 Basics 9 August 29th, 2007 04:19 PM
Browse to File Control? Aaron Edwards Access 3 September 13th, 2005 01:05 AM
how to browse and load mdb file from access form method Access 1 June 18th, 2005 09:52 AM
Bind records from the table to a datalist control macupryk General .NET 1 October 13th, 2004 11:59 AM
Form does not allow new records Timom Access 1 April 21st, 2004 12:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.