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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option frame issue

Status
Not open for further replies.
Sep 12, 2007
45
US

I am trying to work with 3 options or contents of 3 textboxes on a form that displays several records. The first option is default and is supposed to be the usual choice. Either of the other two can be selected by the user depending on the situation. When the user makes a choice (between 2 and 3), the content of the choice textbox becomes the content in the ‘Main’ textbox which a completely different textbox from the 3 choice textboxes. The ‘Main’ textbox is usually populated with content from the choice number 1 textbox. But if the user chooses option 2 or 3, then contents of 2 or 3 textbox becomes the content of the ‘Main’ textbox. I am using an Option frame for the other two choices/options (choices 2 and 3).
The option frame works (see code below) but when I move to the next record, the choice and change is not saved even though I have a Save button to be used to expressly save the change.
Also, the option frame does not reset when I move to the next record i.e. the selection made with the previous record remains intact though the content in the 'Main' textbox for that record is not affected.

Is there a way to ensure that the selection on the option frame is saved and the option frame resets when the form displays the next record?

Thanks for your help.

----------------------------------------------------
If OptFrame.Value = 2 Then
Me.txtMain.Value = Me.txtOptRelatedChoice2
Me.txtMainDate.Value = Me.OptRelatedChoice2Date

ElseIf OptFrame.Value = 3 Then
Me.txtMain.Value = Me.txtOptRelatedChoice3
Me.txtMainDate.Value = Me.OptRelatedChoice3Date

Else
Me.txtMain.Value = Me.txtOptRelatedChoice1
Me.txtMainDate.Value = Me.OptRelatedChoice1Date

End If
-----------------------------------------------------
 
I don't know what you mean by "the choice and change is not saved".
If OptFrame is not bound to a field or some how set in the On Current event of your form, it will not change until you change it. Controls that are bound to a field in a table should be saved as you set values and move to other records.

Duane
Hook'D on Access
MS Access MVP
 
I would also re-consider the names of your controls.[tt]
OptFrame[/tt] I would assume is an Option Button (or a Radio Button) (based on Opt prefix), so the actual name is Frame, which is another type of control.[tt]
txtOptRelatedChoice2[/tt] is an interesting name. Is it a text box (based on txt prefix)? Is it an Option Button (based on the 2nd prefix Opt)?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 


dhookom,

By "The choice and change is not saved" I meant the selection of the option button for that particular record and the subsequent change in the content of the 'Main' textbox based on the selection of option2 or option3 is not saved when I move on to the next record.

“OptFrame” is the frame on which the option buttons are placed which have values 2 and 3. I tried using the option buttons without the frame to no effect earlier. After researching about option buttons, I read that it is better to place them inside a frame. I had set them in the ‘On Current’ event of the form but the changes or selections made were not retained after saving the record. The option buttons are unbound as they are only supposed to assist in the change of the content of the ‘Main’ textbox and have no other purpose as the users are only concerned with the contents of the 'Main' textbox. The selection of the option button is to only show the other users in the future that option 2 or 3 was selected for that particular record deliberately instead of the default choice.


Andy,

To explain what I am trying to do a little better ....... I have three possible solutions (in three textboxes called txtOptRelatedChoice1, txtOptRelatedChoice2, txtOptRelatedChoice3) to a problem from which the user will select the appropriate one based on his or her experience. The first solution is the most obvious one and hence the default one. But if the user feels it doesn’t apply to the given situation, he or she can choose one from the other two. Eventually only one solution will be stored in the ‘Main’ textbox. This whole situation arises because users have to go in and look at the problem at make a selection of the appropriate solution based on their expertise. The option buttons and frame on which they are placed are only meant to help them automatically populate the ‘Main’ textbox instead of copying and pasting the appropriate solution into the 'Main' textbox. I was only using the option buttons because they seemed to be the most applicable solution for this situation. If you know of a better way of addressing this issue, I will be more than happy to use it.

I understand that 'Opt' and 'Choice' in the same name of the textbox is redundant and confusing.

Thank you both for your responses.
 

Duane,

Contents of txtMain and all 3 option textboxes are saved and are bound. Only the option buttons are not bound.

Thanks.
 
You should be able to use code like:

Code:
[highlight #FCE94F][COLOR=#4E9A06]'   grab the frame value and use it in the control names[/color][/highlight]
    Dim intOpt As Integer
    intOpt = Me.optFrame
    Me.txtMain = Me("txtOptRelatedChoice" & intOpt)
    Me.txtMainDate = Me("OptRelatedChoice" & intOpt & "Date")

So, are the values you want to save actually saved?

Duane
Hook'D on Access
MS Access MVP
 

Duane and Andy,

I decided to use command buttons to solve this issue.

I associated a command button with each option textbox which inserts the content of the option textbox in the 'Main' textbox.

When one selection is made, the other two command buttons are disabled and cannot be used. The only enabled/active command button designates its use and tells users that this was the option selected (when the record is reviewed later).

I also placed a reset command button on the form which resets the selection (re-enables all command buttons) if the user changes his or her mind and wants to make a different selection in the future.

Thank you both for your help.
 
I'd have used a combo instead of Option Group, as, only a single choice is ever allowed.

That way, you can have the txtMain and txtMainDate values both in the combo selection. (The combo.column(0) becomes txtMain, and txtMainDate = combo.column(1)).

This cuts down on screen 'real-estate', as there's no need for the option group and no need for txtMain, and, adding new options is a simple matter of adding the option to a table (instead of editing the form).

ATB,

Darrylle




Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top