Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update option group based on textbox result 1

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
0
0
US
I posted this in the "Access Forms" forum, with no luck. I figure that since this is probably going to take a SELECT statment or VB code, that I would try here. Here is where I'm at:

I have a combo box that is based on a table (tbl DACS Country Code Table) for the 'selectable' values. This table contains all of the possible country codes that we use in our office. We also must distinguish between "Special Interest Region" countries and "Non-Special Interest Region" countries. So, armed with this, I made an 'option group' that populates a field in the "2005 LOG" table. It is a simple 'YES' or 'NO' option group.

Here is the request of the endusers; "Can you make it so that if we select an SIR country, that the 'YES/NO' SIR box will automatically check "YES"?

Right now I have it set to a default of "NO" and the endusers have to select "YES" if they encounter one of these SIR countries. How would I go about this? I have another table built that has ONLY these SIR countries...if this would help.

The breakdown:
table name - 2005 LOG
table name - tbl DACS Country Code Table (SIR country values of '1' and non-SIR countries of '2').
table name - tbl Special Interest Region Countries
combobox name - cboCountryPage2
option group name - optgrpSIRCountry (YES and NO options)

I hope that this will help someone to help me with the necessary VB code that will get this to work, thank you.
 

Well, I tried the following (and various others) but it's like threading a needle in the dark!
I am putting it on the 'After Update' Event Procedure of the "txtCountryTableTextPage2" text field:
Code:
Private Sub txtCountryTableTextPage2_AfterUpdate()
    If Me!txtCountryTableTextPage2.Value = 1 Then
    Me!optgrpSIRCountryPage2.Value = 1
Else: Me!optgrpSIRCountryPage2.Value = 2
End If
End Sub

Help?!
 
Okay....let me repost this in a more (hopefully) understandable read:

=====================================================

I have a combo box that is based on a table (tbl DACS Country Code Table) for the values. This table contains all of the possible country codes that we use in our office. We also must distinguish between "Special Interest Region" countries and "Non-Special Interest Region" countries. I also had to make an 'option group' that populates a field in another table -- the "2005 LOG" table (this is our MAIN table). The option group is a simple 'YES' or 'NO' option group.

The request of the endusers is; "Can you make it so that if an SIR country is selected in the 'Country' field, that the 'YES/NO' (option group) Special Interest Region will automatically check "YES"?

Right now I have this option group set to a default of "NO", so the endusers have to select "YES" if when they encounter one of these SIR countries.

How would I go about this?

The breakdown:
table name - 2005 LOG
table name - tbl DACS Country Code Table (SIR country values of '1' and non-SIR countries of '2').
textbox name - txtCountryTableTextPage2
option group name - optgrpSIRCountry (YES and NO options)

I tried the following (and various others) but it's like threading a needle in the dark!
I am putting it on the 'After Update' Event Procedure of the "txtCountryTableTextPage2" text field:

CODE
Private Sub txtCountryTableTextPage2_AfterUpdate()
If Me!txtCountryTableTextPage2.Value = 1 Then
Me!optgrpSIRCountryPage2.Value = 1
Else: Me!optgrpSIRCountryPage2.Value = 2
End If
End Sub
[/code]

Help?!
 
Make sure that your OptionGroup items have Option values of 1 and 2. Just because country codes have that numbering does not mean that option group will be that way.

What happens when you run the code you posted?
 
rubbernilly,

I finally got my code to work (with the help of a few other Access experts...and looking in books, web, etc.).
Here is the final product;

Code:
Private Sub cboCountryPage2_AfterUpdate()
    If Me.cboCountryPage2.Column(3) = 1 Then
    Me.optgrpSIRCountryPage2.Value = 1
Else
    Me.optgrpSIRCountryPage2.Value = 2
End If
    
End Sub

I just knew that it couldn't be that sophisticated, but I am not a VBA programmer (though I want and need to be!)

Thanks for your help.

Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top