Because I am a beginner in Access, I need your help

Safaa

Member
Local time
Today, 04:21
Joined
Jan 3, 2024
Messages
39
I would like help in modifying the code in the following file so that it accepts filling the target field with one value or several values, provided that the values are updated with every double click. A value is transferred to the target field and not transferred all at once. This is exactly what is required in the following image.
 

Attachments

  • LAB MANAGMENT.accdb
    LAB MANAGMENT.accdb
    992 KB · Views: 36
  • زى دا.gif
    زى دا.gif
    839 KB · Views: 44
There are some fields that can only accept one value, and other fields can be filled with one or more values, provided that the method of filling is one by one and not in one batch as in this file.
 
You should never store more than one value in a single field as you are now currently doing as combined text values. You have an improperly designed table structure. Each stool sample could be multiple colors, so you need a StoolColor table. I see you do have a main lookup table already Fixedresults_tbl. I would have structured a little differently and added a column to denote Urine, Stool, or CSF.

Color is a reserved word so you need to use a different word like SColor in your table. Each table needs to have a primary key. I have attached your sample with a few changes to get you started. Instead of adding text values to one single field, I placed a sub form next to your original text box showing how simple sub form selections are to add multiple values of anything. See the stool form.

In this case it's a many to many table structure for adding multiple colors or keytone values from your lookup table for each form.
 

Attachments

Sir, thank you very much.. but this is not what I asked for. I want to do exactly like in the picture... I know that there are fields, like the color field, that only accept one value... so I set it up with properties scroll bars=None.. As for fields that accept one or more values, I made their scroll bars.=Vertical


I also want to delate the update button and make the code at double click
 
Sir, thank you very much.. but this is not what I asked for. I want to do exactly like in the picture..
So here is the problem. You are unlikely to find someone on this forum that will teach you the best way to run with scissors or drive without putting your kids in car seats. I am sure it can be done. Same thing here. Doing what you are asking is not overly complicated, but the down stream effects will just cause you bigger problems. Most members of this forum will focus on doing it right, and not coming up with a solution to do it wrong.

So in your example with Ova. If you store those multiple text values there is no easy way in the future you can query the data and answer simple questions like find patients with Ova value of "Anclystoma ..."
 
Sir, thank you very much.. but this is not what I asked for. I want to do exactly like in the picture... I know that there are fields, like the color field, that only accept one value... so I set it up with properties scroll bars=None.. As for fields that accept one or more values, I made their scroll bars.=Vertical


I also want to delate the update button and make the code at double click
Why some questions don't get answered in online forums
 
I'll respond to this another way. It is clearly possible for you to concatenate strings up to the limit (of 255 characters per string field) for a record. You can even store it that way. But what will you do with it later? Storing multiple strings in a single box now will prevent certain types of searches and JOIN activities from working well - or at all - later. Reports might become difficult. This is an unwise direction.

Your solution is - for those cases when you would allow multiple strings - to concatenate via something similar to the code. You select an item to be added and then concatenate it. The vbcrlf will prevent the strings from running together. I'm not sure WHERE you would place the code because I'm not sure of your data flow.

Code:
if me.ova_list <> "" then
    me.ova_list = me.ova_list & vbcrlf & me.new_ova_item
else
    me.ova_list = me.new_ova_item
end if

Note that there are pitfalls in this approach, not the least of which has to do with how many items could be added before you would start to truncate the text contents. Short text fields can be searched, but if you need more than 255 characters, that would have to be a LONG TEXT field and that can neither be easily searched nor indexed.
 
So here is the problem. You are unlikely to find someone on this forum that will teach you the best way to run with scissors or drive without putting your kids in car seats. I am sure it can be done. Same thing here. Doing what you are asking is not overly complicated, but the down stream effects will just cause you bigger problems. Most members of this forum will focus on doing it right, and not coming up with a solution to do it wrong.

So in your example with Ova. If you store those multiple text values there is no easy way in the future you can query the data and answer simple questions like find patients with Ova value of "Anclystoma ..."
Sir, I thank you very much for your advice, but there are tables in which the patient’s data is stored with the special code, the required tests, and the result of each analysis. Through the query, I can find patients who suffer from hookworms, giardia, or others. This example is not the entire program, but I have stored all the values from possible to use
With all fields with all forms in one table to call it from the field name. This is to facilitate selection instead of typing in every field. I know what I am doing well. If you can help me get the result shown in the picture, please help me
 
I'll respond to this another way. It is clearly possible for you to concatenate strings up to the limit (of 255 characters per string field) for a record. You can even store it that way. But what will you do with it later? Storing multiple strings in a single box now will prevent certain types of searches and JOIN activities from working well - or at all - later. Reports might become difficult. This is an unwise direction.

Your solution is - for those cases when you would allow multiple strings - to concatenate via something similar to the code. You select an item to be added and then concatenate it. The vbcrlf will prevent the strings from running together. I'm not sure WHERE you would place the code because I'm not sure of your data flow.

Code:
if me.ova_list <> "" then
    me.ova_list = me.ova_list & vbcrlf & me.new_ova_item
else
    me.ova_list = me.new_ova_item
end if

Note that there are pitfalls in this approach, not the least of which has to do with how many items could be added before you would start to truncate the text contents. Short text fields can be searched, but if you need more than 255 characters, that would have to be a LONG TEXT field and that can neither be easily searched nor indexed.
But there is no list specific to the ova, and it is not one specific to the worm. but all the contents of forms of urine, stool, bone marrow fluid, and semen report are present in one list. I am sure you have not looked at the file. Please, if you have time, take a look at the file.
 
I know what I am doing well.
Then do not sell yourself as a begginner in need of help. The responses we would give to a seasoned programmer are very different from a beginner.

Did you write the code in basFillFieldsFromListbox? If so what problems are you having? I do not understand since it seems most of the code is there to do what you want.

Can you tell us which form and which textbox is to be filled from the listbox?

The problem I see and not included is assume I have a textbox to be filled from choices in a listbox
If the values in the textbox are
Dog
Cat
Mouse

Which is really a string with VBCRLF between the values

When you click again for the listbox how are you going to exclude from the selections Dog, Cat, and Mouse so that you do not click them again. It can be done by not trivially.

I am sure you have not looked at the file. Please, if you have time, take a look at the file
We have all looked at the file, and thus are questions on what you are doing. When we see this.

When we see this a text field holding multiple values, we are going to question what you are doing.


color
Bloody
Brownish
Darkbrown
Greenish
Brownish
stool_tbl



If I absolutely had to do this, it would work this way.

1. Click on the text box and open generic List form. Pass in the rowsource based on the field.
2. If choices already exist in the text box Need to parse those
("Bloody", "Brownish"....)
3. Create rowsource "Select FixedResults from FixedResults_Tbl where FixedName = "(Urine) Color" and FixedName not in ("Bloody", "Brownish"...)
4. Now in the multi select listbox Highlight the choices "Bloody", "Brownish"
5. User selects or unselects and rebuilds the list.
6. Pass list to form.
 
Did you write the code in basFillFieldsFromListbox? If so what problems are you having? I do not understand since it seems most of the code is there to do what you want.

The field that may contain more than one value is updated at once, such as this image
 

Attachments

  • update all value.gif
    update all value.gif
    473.4 KB · Views: 24
But what I want is for the field to be updated one value after another, like this image
 

Attachments

  • value then another value.gif.gif
    value then another value.gif.gif
    839 KB · Views: 22
Can you tell us which form and which textbox is to be filled from the listbox?



It is not one form, but more than one form. They are forms urine, stool, semen, and CSF . Each form has fields that are filled out by selecting values from the same listbox. Some fields are filled with one value and others are filled with one or more values
 
When you click again for the listbox how are you going to exclude from the selections Dog, Cat, and Mouse so that you do not click them again. It can be done by not trivially.
I do not care about this point at the present time. I will put a condition on the field that does not accept repeated values
 
For example, when you double-click on the color field in the stool form, the listbox opens to choose one value. However, when you click on a field that may include more than one value, such as the ova,( is not present in the form )it is supposed to open the same listbox to choose the type of ova. Because the patient may have two or more types of ova, I have put it in the code to allow him to add more than one value. All I am asking now . Idont want target field is filled in at once with all the chosen values, but i want with all doube click on thelistbox choce one value then another if i click again to the same field .
as picture attached at the beginning.
 
For example, when you double-click on the color field in the stool form, the listbox opens to choose one value. However, when you click on a field that may include more than one value, such as the ova,( is not present in the form )it is supposed to open the same listbox to choose the type of ova. Because the patient may have two or more types of ova, I have put it in the code to allow him to add more than one value. All I am asking now . Idont want target field is filled in at once with all the chosen values, but i want with all doube click on thelistbox choce one value then another if i click again to the same field .
as picture attached at the beginning.
And how do you plan to remove a value from that list? Because the values in that text box are jumbled together, you box yourself into a corner unless you want to just erase the whole thing and start over.
 
And how do you plan to remove a value from that list? Because the values in that text box are jumbled together, you box yourself into a corner unless you want to just erase the whole thing and start over.
When focusing on any field in the form, an unbound field is filled with the name of the field, plus the name sub, which symbolizes the name of the form, such as stool, for example, so the value of the unbound field will be color(stool), for example. I placed a button in the form, and when click btn, the value of the unbound field is transferred to a new form, through which values are added or values are modified for the same field. It is very simple.
 
Is there anyone who can solve it?
Yes, there are several people here who could invest time and effort in making it work, sort of, with the current design.

But they would then have to live with the knowledge that they'd done so.
 
I see that all I get on this blog are topics such as expression class in school only, to no avail
 
Last edited:

Users who are viewing this thread

Back
Top Bottom