Wrox Programmer Forums
|
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 July 25th, 2003, 03:40 PM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with Form Code

I have the following code:

Private Sub FAFA4_Change()
FAFA5.Value = ""
FAFA5.Requery
FAFA23.Value = ""
FAFA23.Requery
End Sub

The objects are ComboBoxes. My purpose is to have the second box (FAFA5) popluated based on the choice in the first box (FAFA4), and so on.

This code works with one major glitch - it applies itself to all records rather than just the one that was changed.
Thus, if someone changes the choice in ComboBox FAFA4 for record 2, all the other records also have their other ComboBoxes cleared and requeried.

How to I modify the code to only apply to the ComboBoxes for the record that was changed?

Thanks,

Bryan Brassell

Bryan A. Brassell
 
Old August 6th, 2003, 11:32 AM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you give us a little more detail?

Are these combo boxes all listed in the same record, or does the table that these all belong to have just the couple fields?

Basically, can you send the list of the fields in the recordset? I'm sure I could help if I had more information.

John
 
Old August 18th, 2003, 02:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by BryanBrassell
My purpose is to have the second box (FAFA5) popluated based on the choice in the first box (FAFA4), and so on.
Bryan,

First, don't do this on a continuous form. That will eliminate the "all or nothing" problem you're having. Use a single form that you can scroll record-by-record with using record selectors.

As for the comboboxes changing their rowsources based on the selection of other comboboxes, that's not too hard once you know what SQL language to write. Suppose, for example, you have Me.cboChoice1 and Me.cboChoice2. You would reset Me.cboChoice2's rowsource on Me.cboChoice1's AfterUpdate event:
Code:
   Me.cboChoice2.Rowsource = {some SQL statement based on Me.cboChoice1}
   Me.cboChoice2.Requery
   What exactly to use for the SQL statement depends on Choice1's relationship with Choice2.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Form Code with VBA emt_101 Access VBA 2 October 17th, 2008 11:45 AM
Code help - Form misbehaving jeremy1048 Access 1 May 13th, 2008 06:26 AM
Refresh form code CrArC Access VBA 1 October 28th, 2006 08:57 AM
can't create a form in code-behind hertendreef ASP.NET 2.0 Basics 0 May 30th, 2006 04:14 AM
Code transfer to form!field Quixote Access VBA 1 July 11th, 2005 09:51 AM





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