Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 14th, 2004, 12:45 PM
Authorized User
 
Join Date: Jul 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do you do this in Access?

I have a form that has an option group with 2 radio buttons, then below the option group there are fields with combo boxes where the user can select various codes from the dropdowns.

These codes can exist as data in columns of TABLE1 or TABLE2. The codes are all housed in the same code table and the code table doesn't have a column which specifies that a code is a "TABLE1" code or "TABLE2" code. So, yes, theoretically a user could enter a "TABLE1" type code in "TABLE2" and vice versa, but that's an integrity issue that's seperate from this problem.

What I need to do is be able to return rows from a query depending upon which radio button is selected in the form. BUT THE RADIO BUTTON DICTATES THE JOIN.

Thus, if they select button1, then I need my query to join against TABLE1, and if they select button2, I need my query to join against TABLE2.

The query will be executed as a Click Event for a button on the form. I do not want to create two seperate buttons to invoke each query seperately since it's not as clean an approach.

Is what I want to do possible in Access? (running Access 2003)

All responses appreciated. Thanks!


 
Old August 22nd, 2004, 07:59 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not see an easy way in Access to change the table where u run ur query. Making a second query, one for each radio button, would not be possible?
Trully Penta.

 
Old August 23rd, 2004, 09:53 AM
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

Suppose you have the option group with the two radio buttons. Suppose the option group is called grpCodeGroup and the two options buttons are called optTable1 and optTable2. When you click optTable1, then grpCodeGroup will equal 1. When you click optTable2, grpCodeGroup will equal 2. On your option group's AfterUpdate event, you have something like this:

Code:
    If Me.grpCodeGroup = 1 Then
        Me.cboMyCombobox.Rowsource = "SELECT [Field] FROM Table1 WHERE..."
    Else
        Me.cboMyCombobox.Rowsource = "SELECT [Field] FROM Table2 WHERE..."
    End If

For each row source, change the [Field] and WHERE clause to specify what you want.




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





Similar Threads
Thread Thread Starter Forum Replies Last Post
401.3 Access denied due to Access Control List cforsyth .NET Framework 2.0 8 May 28th, 2009 01:56 PM
SQL Access/ASP.NET data access issue saeta57 SQL Server ASP 1 July 4th, 2004 04:29 PM
SQL Access/ASP.NET data access issue saeta57 Classic ASP Databases 1 July 4th, 2004 03:32 PM
ADE file in Access 2000 <---> Access XP ginoitalo Access 3 April 14th, 2004 09:06 PM
Access XP VBA compatibility issues w/ Access 2000 bourgeois02 Access VBA 1 August 19th, 2003 04:14 PM





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