Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2004, 09:37 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
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:)

:)

Reply With Quote
  #2 (permalink)  
Old November 16th, 2004, 03:42 PM
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
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
Reply With Quote
  #3 (permalink)  
Old November 16th, 2004, 05:28 PM
Authorized User
 
Join Date: Sep 2004
Location: Twickenham, , United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old November 17th, 2004, 01:26 PM
Authorized User
 
Join Date: Sep 2004
Location: Twickenham, , United Kingdom.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:59 PM.


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