Option group linked to Field (1 Viewer)

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
I am new to access and I have created a option group with 4 options in a form:

Option 1: 0-8
Option 2: 9-12
Option 3: 13-14
Option 4: >=15

Each of the above options has a seperate bound text box, i.e a total of 4 text boxes one for each option. I would like one of the 4 text boxes, created in my table/query and now part of my form, to be activated when the option related to the text box is selected so that data can be entered in this text box, whilst all the others 3 text boxes remain deactivated, therefore only allowing one entry for the 4 options and only one selection of each of the 4 options. How do I link each bound text box to each option within the group. :rolleyes:
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:56
Joined
Jul 2, 2005
Messages
13,826
And will you allow the user to change their mind and select a different option? How about after they have already filled in one of your textboxes? We might be able to offer some different suggestions if you will present more details as to what you are trying to achieve.
 

jsv2002

Registered User.
Local time
Today, 04:56
Joined
Feb 11, 2009
Messages
240
In the option group afterupdate create an event procedure something like:

If MenuOpt.Value = 1 Then

Me.TextBox1.Enabled = True

ElseIf MenuOpt.Value = 2 Then

Me.TextBox2.Enabled = True

ElseIf MenuOpt.Value = 3 Then

Me.TextBox3.Enabled = True

End if

Your form Onload would probably need something like:

Me.TextBox1.Enabled = False
Me.TextBox2.Enabled = False
Me.TextBox3.Enabled = False

to make sure that they were disabled initially until a group option is made might need to play around with variations so if another option is selected to disable the others which could be included in the afterupdate above but you should get the general idea from this :)

good luck with your project John

EDIT:

RuralGuy is completely correct you would need to clear selections if user changed mind which can be done but as pointed out more info needed. :)
 
Last edited:

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
Many thanks for your response. Yes, I hadn't though of user changing their minds, particularly if the data they entered against a particular option was incorrect, particulrly after they had filled in text box.
 

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
Thank you for you response. I have tried as you have suggested. The 4 options that I have are disabled until I select an option. However, when I select any of the 4 options only text box 1, relation to option 1, data changes from one to 4 depending on the option.

I would like to select an option and then the text box related to the option is activated so that I can enter text.

Any other suggestions would be of great help.
 

jsv2002

Registered User.
Local time
Today, 04:56
Joined
Feb 11, 2009
Messages
240
Without knowing exactly what you have done its a bit hard to advise as ruralguy said earlier you would need to clear entered text if user changed selection maybe: Me.TextBox1 = Null

To be honest could do with seeing an example of what you have done rather than giving you suggestions that may/maynot work.

regards john
 

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
Many thanks for response. Here goes:

I have crated 4 fields within a table, namely

Field 1: Score A
Field 2: Score B
Field 3: Score C
Field 4: Score D

Each score has a validation rule:
Score A: 0-8
Score B: 9-12
Score C: 13-14
Score D: >=15

I have created 4 options within a form related to each of the above:

Option 1: text box Score A
Option 2: text box Score B
Otpion 3: text box Score C
Option 4: text box Score D

These fields also appear within a form next to each option within a frame, i.e.:

o Option 1: Score A
o Option 2: Score B
o Option 3: Score C
o Option 4: Score D


The frame has the following code added within properties of the frame - Event - After Update:
Option Compare Database
Private Sub Form_Load()
Me.ScoreA.Enabled = False
Me.ScoreB.Enabled = False
Me.ScoreC.Enabled = False
Me.ScoreD.Enabled = False
End Sub
Private Sub OptGrpAuditScore_AfterUpdate()

If Option1.Value = 1 Then
Me.ScoreA.Enabled = True
ElseIf Option2.Value = 2 Then
Me.ScoreB.Enabled = True
ElseIf Option3.Value = 3 Then
Me.ScoreC.Enabled = True
ElseIf Option4.Value = 3 Then
Me.ScoreD.Enabled = True
End If
End Sub

Each time an option is selected, i.e. Option 2, then the text box for Score B (Field Name: ScoreB) should be enabled.

Also if the use has selected the wrong option and therefore entered the wrong info in the related text box then they should somehow be able to correct this and then select the correct option and enter the correct data in related text box to the selected correct option.

Does the above make any sense? Hhhhheeeeellllp.
 

jsv2002

Registered User.
Local time
Today, 04:56
Joined
Feb 11, 2009
Messages
240
Have a look at the attached it will do what you want (haven't put any validation rules in you might be better using comboboxes to limit selections anyway)

Its long winded I admit and the code is in form OnCurrent/OnLoad and MenuOpt AfterUpdate the best I can say is that it works and pretty much does what you are looking for but had I more time would try to come up with something better :(

good luck John
 

Attachments

  • Test8.zip
    40.6 KB · Views: 119

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
Thank you for you reply and your attachment. I have tried since you sent your reply and attachment to open form and debug but have been unable to.

Sorry to be a pain, but am deperately trying to get it to work and can't seem to be able to do so and hope that you would be able to assist in my desperate need of help, extreley deperate. Please Help.
 

jsv2002

Registered User.
Local time
Today, 04:56
Joined
Feb 11, 2009
Messages
240
What do you mean you can't open/debug? what version of access are you using? do you mean you can't open the databse or unzip the file? Glad to help but need a bit more information....

John :)
 

herronar

Registered User.
Local time
Today, 09:26
Joined
Mar 15, 2009
Messages
15
Thank you for you reply. You are absolutely right.

I had tried to open your file without downloading WinZip. Due to this it had a run-time error. I have now bought WinZip and your fab form is working fine.

Many, many, mmmmaaaannnnyyy thanks.
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:56
Joined
Jul 2, 2005
Messages
13,826
Thank you for you reply. You are absolutely right.

I had tried to open your file without downloading WinZip. Due to this it had a run-time error. I have now bought WinZip and your fab form is working fine.

Many, many, mmmmaaaannnnyyy thanks.
Now that you bought WinZip, aren't you using Windows XP or Vista? Both know how to unzip that file and it comes with the OS.
 

Users who are viewing this thread

Top Bottom