dropbox choices

ovidius

New member
Local time
Today, 08:34
Joined
Nov 5, 2011
Messages
2
I have a dropbox with 5 values corresponding to 5 different tables. The 5 tables have some fields with common name and others unique to each table. All the fields from all of the 5 tables are fields in my form. I want to do the following:
After I choose the table from the dropbox I want the fields with the common name to be associated with the chosen table and the unique fields enabled and all the other fields disabled so the user can't write in them
 
Here is a simplified version of what you're trying to do, using a Combobox selection to set the RecordSource of the Form. It Enables the Textbox for the Field that is specific for the Table being used, and Disables the Textbox for the Field that is not appropriate for the Table.
Code:
Private Sub TableComboBox_AfterUpdate()

 Select Case Me.TableComboBox
  
  Case "TableOneValue"
    
    Grade.Enabled = True
    Religion.Enabled = False
    Me.RecordSource = "TableOne"
   
  Case "TableTwoValue"
    
    Religion.Enabled = True
    Grade.Enabled = False
    Me.RecordSource = "TableTwo"
 
 End Select
In this example
  • TableComboBox is the name of the Combobox
  • The Selections in the Combobox are "TableOneValue" and "TableTwoValue"
  • Tables are named "TableOne" and "TableTwo"
  • TableOne has a Field named Grade
  • TableTwo has a Field named Religion
  • Both Tables have Fields named NName and RRank

As I said, this is a very simple example of how this can be done! It doesn't address the question of how you want your Form to appear before a selection is made from the Combobox. Doing this for two Tables that share two Fields, with each Table having one Field only germane to itself was a bit of work!

Expanding this to include five Tables, with some Fields being common to some Tables and other Fields only being specific to a single Table seems, to me, to be a project requiring way more effort than it could possibly be worth, one I would never attempt!

Why not simply have a tailored Form for each Table and use the Combobox to Open the appropriate Form?

You could start with one Form, use it as a Template, and add/delete the Textboxes that are or aren't appropriate for each Form.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom