0

I am working on an Access 2010 form which where the user can select a record in the form header via a combobox and then build up elements related to the selected record in the detail section of the form. The default view of the form is set to continuous forms.

One of the controls in the detail section of the form is a combobox control. What I want to do is set the enabled property of a textbox on the same row of the form to false based upon a selection from the combobox. The code I am running is:

If Me.cboElementType = "Contract Shrink" Then
  Me.txtElementID = ""
  Me.txtElementID.Enabled = False
EndIf

This works, but it sets all instances of the textbox (txtElementID) to enabled = false. What I want to have happen is for the txtElementID to have a different enabled setting for each row in the detail section based upon the selection of the combobox cboElementType. So, if cboElementType = "Contract Shrink" on row 1 of the scrolling detail section, the txtElementID.Enabled would be set to false for that row. If cboElementType = "Cost Group" on row 2 of the scrolling detail section, then I'd like txtElementID.Enabled to be False on row 1 of the detail section and txtElementID.Enabled to be True on row 2.

Can anyone confirm or deny that this can be done and, if it can be done, how you would suggest it be accomplished? No matter which way this goes, thanks for help.

3 Answers 3

1

You cannot do it through VBA like you did, you need to use Conditional formatting, there you have an option to set the Enabled property.

Sign up to request clarification or add additional context in comments.

Comments

0

try in Form_Current() event like

Private Sub Form_Current()
If Me.cboElementType = "Contract Shrink" Then
  Me.txtElementID = ""
  Me.txtElementID.Enabled = False
EndIf
end sub

Comments

0

I have been searching for days for how to access an individual record on continuous form and I am willing to say it is not possible, but I have a trick that I will share here. I have an investments database, user gets in and writes a proposal and then there is a meeting where either the project is approved (given money) or it is cancelled. However, there are many more states a project can be in, Proposal, Execution, etc. but only Approved/Cancelled can happen at this stage. I created a MockBool field in the Project table. I put that on the continuous form and when the form is closed I run this:

rs_frm=me.recordset
rs_frm.movefirst
while not(rs_frm.eof)
  if rs_frm("MockBool") then
    rs_frm.edit
    rs_frm("ProcessStatus")="Cancelled"
    rs_frm("MockBool")=false
    rs_frm.update
  end if
  rs_frm.movenext
wend

I had days of searching and had an epiphany so I thought I would share.

1 Comment

Don't see how this answers question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.