Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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
 
Old November 16th, 2004, 09:37 AM
Registered User
 
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pointing a Sub-form to a particular record.

I'm in need of some assistance. I have a form displaying information on a particular record. On that form I have a combo box with details of members of staff this particular record refers to, the combo box is just selecting the name of the member of staff, this data is stored in an other table. I'm looking to display information on these members of staff on the same form, for instance job title ect... I attempted adding a sub form and trying to get it to open to the correct record, this failed the code I was using was a variation on some code I have used before.

DoCmd.OpenForm "formName", , , "NAME = " & Me.NAME

I couldn't convince it to accept

SubForm.SourceObject "formName", , , "NAME = " & Me.NAME

Any help would be greatly appreciated.
I don't need the data to be displayed in a sub form necessarily.

Simon:)

:)

 
Old November 16th, 2004, 03:42 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

If you want to browse to a record based on a selection from a combo box, then you just need to use the combo box wizard, and tell it to find a record on your form.

Tell it which field to use as the look up, in this case staff member names. Then when you use the combo box to enter a staff member's name, the form will move to that staff member's record.

Be sure to go to the query behind the combo box and sort alphabetically.

Also, on the form's On Current event, synchronize the combo box with the table's primary key, like this:

Sub On Current
   MyComboBox = tblStaffPK
End Sub

Is this what you are trying to do?

mmcdonal
 
Old November 16th, 2004, 05:28 PM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paulsh Send a message via Yahoo to Paulsh
Default

I have been trying to get this right for a few days now and I have to say (unhappily) without success.

I have two tables, linked by a field (fldA). The subform has multiple instances or records which correspond to fldA while the mainform only has 1 record related to fldA.

When I do as you suggest, the subform reacts as you have indicated... Great. But,
the mainform data stays at the current record and even the navigation button remains pointing to the origional record.

How do I get the mainform data to cycle to the record that I have chosen in the combobox.

I'm sorry if I appear dense, I assure you i'm not, but I have been struggling with ths for a while.

Paul

Paul
 
Old November 17th, 2004, 01:26 PM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paulsh Send a message via Yahoo to Paulsh
Default

Thanks for your help. Problem solved...

My combobox was linking to the subform because for some reason when I placed the combobox on the form, my subform was already present. Once i removed the subform and rebuilt the mainform placing the combobox on this form first and then later building the subform, the problem sorted itsef.

Great forum. Keep it up.

Paul

Paul





Similar Threads
Thread Thread Starter Forum Replies Last Post
Log4j load balanced tomcat pointing same webapp wesley Apache Tomcat 0 April 24th, 2008 08:40 PM
passing unique record from form to form Baconant Beginning VB 6 1 January 2nd, 2008 06:20 PM
Subdirectory pointing page in main directory vivek_inos ASP.NET 2.0 Basics 2 December 4th, 2006 03:09 AM
Localhost was pointing to other server leion General .NET 1 January 6th, 2005 03:21 AM
Include Files pointing to corrrect path apd8x Classic ASP Basics 1 July 30th, 2003 08:37 AM





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