One forms controls affects all records

cmpcperc

New member
Local time
Today, 06:41
Joined
Jun 25, 2013
Messages
3
Dear all
Im new to this and Access too but have come quite far in my project in a short time and am loving learning the aspects to databases and their features. Ive got a problem, I've tried many things and also tried many forums. I hope this is the correct forum to place this problem.

I have a form where you enter a Case number (Primary key) and EmployeeID (foreign Key), the employeeID must match a employeeID held in the employee table.
Within this Case form, I have a subform called Account which has an autonumber Primary key called accountID. Each of these accounts will have a questionnaire. So I created the questions in the same table (account). So Q1, Q2, Q3 etc. which are Questions relating to each AccountID, one accountID can have one questionnaire.
What is working fine is I can enter an account NUMBER which is a field in my account table (which creates a new AccountID(autonumber)) and can happily check the checkbox, fill out the text fields move to the next record and the checkbox is unticked and text boxes are blank (default state) which is great as I want them to ready for new input (new accountnumber/id).

My problem is assume I create my very first account number which would be say AccountID(0), I want all textboxes for the three questions disabled until the checkbox is ticked. So thats ok, I can put the default value of chkbox to FALSE, and in VBA I can do the on_checkbox_click, if chkbox.value = true then textbox1.enabled = true else textbox1.enabled = false. I can do that for the other two textboxes in the Chkbox click event.
When I Tick the checkbox it enables the textboxes, which is good, but when I create/move to the next record, instead of these textboxes being disabled as default, they are enabled because i ticked the chkbox for the first record. I dont want the manipulation of one AccountsIDs questionnaire to affects the other records. If I add an unbound textbox which I want to display a message if the chkbox is ticked, then if I tick it on one record, it has the displayed message on all records. How can this be if each questionnaire is independently i.e each questionnaire is for ONE accountID.

It seems the textboxes etc are not unique to each accountID but they should be because they are in the Account table and when I enter values and use the checkboxes without doing the disabling or showing a textbox comment, they are separate and work great, but when I use my code to manipulate the flow of a questionnaire for each account i.e enabling textbox/showing textbox comment, it changes the formatting on the other records questionnaire which I don't want as each questionnaire will be different, so a chkbox may enable a question on one ID but not on another as it wont be relevant, so at the moment I only have ONE truly working questionnaire which works for ONE account :(, but I want it to work uniquely for each account.

I really appreciate your time and help. I understand I may have not cut to the chase as its a long question, but I had to think the problem out and give you as much informaiton as possible to help me.

Thank you very much.
 
I have skimmed throught your post. If you cut your future posts down to the essence, you might enjoy more response.

When you have controls displaying some values of a record, and then you change some property of a control, that property remains changed for that control, no matter which record you subsequently go to. There is only one control, but the value it displays hinges is the one of the current record.

If you have code changing properties of controls, you need to run it when the change takes place (eg if you click some button). If that is to depend on which record is current record, then you need to run some code in the On Current event - that event is triggered each time another record becomes current record.

If the above does not answer your question, then write your question in a sentence or two.
 
Hello, sorry about the lengthy question.

Even with using oncurrent, (say disabling textboxes), my problem is if I move to the next record, it will run that code and disable textboxes which is a similar problem.

As an example say on Record 1 I want to have a checkbox which if ticked enables 3 textboxes (questions) for this record. If I tick this chkbox on record one, it will enable the textboxes ready for input, if I move to record 2, instead of them being disabled they are enabled as I ticked them on record 1. Now if I do the oncurrent, it will disable them yes, but then when I move back to record 1, they will be disabled again which I don't want.

I want the enabling/disabling etc of each record number to relate to just that record and not change the values of other records.

Thanks
 
You can only treat controls differently in Single Form - not in Continuous Form or Datasheet. If the way you treat controls depends on the record, then the information that determines the treatment must be in the record too. Your checkbox must thus be bound to a field in the table/query, and then in OnCurrent handler, and you can check it's value and set the controls as desired.

In Continuous Form or Datasheet you can do some coloring of controls using Conditional Formatting (google it) - you can e.g. set background colour of a control differently from record to record, depending on some value in the record.
 
Thank you very much, this is working great and is an alternative to disabling etc.

I have an 'expression is' Check.Value=True then show Green on the relevant textbox but can I get this textbox to display text as well.

So if check.Value=True then turn textbox green (which it doeS) and display predefined text.

So something like

Expression is check.Value=True then me="ABCDEFG"

Thanks again.

I may be able to sleep tonight now!
 

Users who are viewing this thread

Back
Top Bottom