473,785 Members | 2,794 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with displaying data from two tables on one form

Hi!
I haven't been using Access for a very long time and I forgot everything :)
I will be very greatful for help since I have been fighting with this
problem for a few hours...

I have three tables: Medicines (ID_Medicine, ID_MedicineGrou p,
MedicineName), MedicineGroups (ID_MedicineGro up, MedicineGroupNa me) and
Treatment (ID_MEDICINE, ID_CONSULT, ID_COMMENT). After the user chooses
appropraite MedicineGroup and later Medicine from appropriate Combos I add
records to table. Then I must show all the records in a subform which were
added during current consultation with an ability to input Comment regarding
the usage of medicines. It would be no problem - simply display all three
fields (ID_MEDICINE, ID_CONSULT, ID_COMMENT) but the problem is that I also
need to display the names of the medicine and medicinegroup which are in
different table.

I tried 3 solutions:
1. When I simply changed source of the form to include other tables it was
not possible to edit the values (comments). I assume that it is as it should
be and there is no way to make Access display data from other tables on the
same form and change data in only one table?

2. When I tried to use a subform in a subform which shows me the names
everything is all right but unfortunately then I am not able to display many
medicines at once since it is only possible to show single record at a time.

3. I also tried to use an editbox which should be somehow filled with a text
from a query. I created a query

SELECT [Medicines].[ID_MEDICINE], [Medicines].[MedicineName],
[MedicineGroups].[MedicineGroupNa me]
FROM Medicines, MedicineGroups
WHERE Medicines.ID_ME DICINEGROUP = MedicineGroups. ID_MEDICINEGROU P;

and I tried something like
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE=" &
[ID_MEDICINE])
as the value of the edit box but another problem apperas - dlookup is
calculated once and all records have the same value in the edit box no
matter what ID.MEDICINE is (all fields have the value connected with the
ID.MEDICINE of the 1st record)

Any suggestions? I will be very very very grateful for any help since I am
out of ideas
Chris Bartosiewicz
Nov 13 '05 #1
4 3652
Re your solution 2, open the subform in design view, and change its Default
View property to Continuous form or Datasheet. You will then be able to see
multiple records, one per row.

Use a combo for ID_MEDICINE, and set the first column of the combo to
zero-width so it displays the medicine name rather than the id in the
subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Krzysztof Bartosiewicz" <bb***@klub.chi p.pl> wrote in message
news:d4******** **@nemesis.news .tpi.pl...
Hi!
I haven't been using Access for a very long time and I forgot everything
:) I will be very greatful for help since I have been fighting with this
problem for a few hours...

I have three tables: Medicines (ID_Medicine, ID_MedicineGrou p,
MedicineName), MedicineGroups (ID_MedicineGro up, MedicineGroupNa me) and
Treatment (ID_MEDICINE, ID_CONSULT, ID_COMMENT). After the user chooses
appropraite MedicineGroup and later Medicine from appropriate Combos I add
records to table. Then I must show all the records in a subform which were
added during current consultation with an ability to input Comment
regarding the usage of medicines. It would be no problem - simply display
all three fields (ID_MEDICINE, ID_CONSULT, ID_COMMENT) but the problem is
that I also need to display the names of the medicine and medicinegroup
which are in different table.

I tried 3 solutions:
1. When I simply changed source of the form to include other tables it was
not possible to edit the values (comments). I assume that it is as it
should be and there is no way to make Access display data from other
tables on the same form and change data in only one table?

2. When I tried to use a subform in a subform which shows me the names
everything is all right but unfortunately then I am not able to display
many medicines at once since it is only possible to show single record at
a time.

3. I also tried to use an editbox which should be somehow filled with a
text from a query. I created a query

SELECT [Medicines].[ID_MEDICINE], [Medicines].[MedicineName],
[MedicineGroups].[MedicineGroupNa me]
FROM Medicines, MedicineGroups
WHERE Medicines.ID_ME DICINEGROUP = MedicineGroups. ID_MEDICINEGROU P;

and I tried something like
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE="
& [ID_MEDICINE])
as the value of the edit box but another problem apperas - dlookup is
calculated once and all records have the same value in the edit box no
matter what ID.MEDICINE is (all fields have the value connected with the
ID.MEDICINE of the 1st record)

Any suggestions? I will be very very very grateful for any help since I am
out of ideas
Chris Bartosiewicz

Nov 13 '05 #2
> Re your solution 2, open the subform in design view, and change its
Default View property to Continuous form or Datasheet. You will then be
able to see multiple records, one per row.
Unfortunately it is not possible to use continuous form if a subform is
present inside the form. And I don't want to use a datasheet.

Use a combo for ID_MEDICINE, and set the first column of the combo to
zero-width so it displays the medicine name rather than the id in the
subform.
Yes, that would be a solution but I wanted to use edit box since the value
is meant for display only (ID_MEDICINE and ID_CONSULT are fixed and only
Comment field should provide the user with the ability to edit data) - a
combo which doesn't allow to change its value doesn't look very good.

Chris Bartosiewicz

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Krzysztof Bartosiewicz" <bb***@klub.chi p.pl> wrote in message
news:d4******** **@nemesis.news .tpi.pl...
Hi!
I haven't been using Access for a very long time and I forgot everything
:) I will be very greatful for help since I have been fighting with this
problem for a few hours...

I have three tables: Medicines (ID_Medicine, ID_MedicineGrou p,
MedicineName), MedicineGroups (ID_MedicineGro up, MedicineGroupNa me) and
Treatment (ID_MEDICINE, ID_CONSULT, ID_COMMENT). After the user chooses
appropraite MedicineGroup and later Medicine from appropriate Combos I
add records to table. Then I must show all the records in a subform which
were added during current consultation with an ability to input Comment
regarding the usage of medicines. It would be no problem - simply display
all three fields (ID_MEDICINE, ID_CONSULT, ID_COMMENT) but the problem is
that I also need to display the names of the medicine and medicinegroup
which are in different table.

I tried 3 solutions:
1. When I simply changed source of the form to include other tables it
was not possible to edit the values (comments). I assume that it is as it
should be and there is no way to make Access display data from other
tables on the same form and change data in only one table?

2. When I tried to use a subform in a subform which shows me the names
everything is all right but unfortunately then I am not able to display
many medicines at once since it is only possible to show single record at
a time.

3. I also tried to use an editbox which should be somehow filled with a
text from a query. I created a query

SELECT [Medicines].[ID_MEDICINE], [Medicines].[MedicineName],
[MedicineGroups].[MedicineGroupNa me]
FROM Medicines, MedicineGroups
WHERE Medicines.ID_ME DICINEGROUP = MedicineGroups. ID_MEDICINEGROU P;

and I tried something like
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE="
& [ID_MEDICINE])
as the value of the edit box but another problem apperas - dlookup is
calculated once and all records have the same value in the edit box no
matter what ID.MEDICINE is (all fields have the value connected with the
ID.MEDICINE of the 1st record)

Any suggestions? I will be very very very grateful for any help since I
am out of ideas
Chris Bartosiewicz


Nov 13 '05 #3
Krzysztof Bartosiewicz wrote:
Hi!
I haven't been using Access for a very long time and I forgot everything :)
I will be very greatful for help since I have been fighting with this
problem for a few hours...

I have three tables: Medicines (ID_Medicine, ID_MedicineGrou p,
MedicineName), MedicineGroups (ID_MedicineGro up, MedicineGroupNa me) and
Treatment (ID_MEDICINE, ID_CONSULT, ID_COMMENT). After the user chooses
appropraite MedicineGroup and later Medicine from appropriate Combos I add
records to table. Then I must show all the records in a subform which were
added during current consultation with an ability to input Comment regarding
the usage of medicines. It would be no problem - simply display all three
fields (ID_MEDICINE, ID_CONSULT, ID_COMMENT) but the problem is that I also
need to display the names of the medicine and medicinegroup which are in
different table.
Here is an alternative method. In your main form, have the consult
info. In your subform, based on a table with the following fields, have
the fields ConsultID (to link), the MedicineGroup (combo), the
MedicineID (visible no), the MedicineName (a calced field that displays
the medicine name based on medicineID, and Comments.

In the AfterUpdate event of the MedicineGroup, call a form (modal) that
displays a listbox of all medicines for that medicine group. Provide a
Select and Cancel buttons. If a person dbl-clicks on a medicine in the
listbox for that group, or single clicks and presses the Select button,
that value is stored into the MedicineID field. If cancel, nothing.
Requery the calced medicine description field when the form is closed.
Also, allow the user to dbl-click on the description field to pull up
the list box (if a group has been selected). Now add the comments....or
pull the comments that may be contained in comments already created for
that medicine and allow additional comments to be made. This way the
subform can be continuous.

I tried 3 solutions:
1. When I simply changed source of the form to include other tables it was
not possible to edit the values (comments). I assume that it is as it should
be and there is no way to make Access display data from other tables on the
same form and change data in only one table?

2. When I tried to use a subform in a subform which shows me the names
everything is all right but unfortunately then I am not able to display many
medicines at once since it is only possible to show single record at a time.

3. I also tried to use an editbox which should be somehow filled with a text
from a query. I created a query

SELECT [Medicines].[ID_MEDICINE], [Medicines].[MedicineName],
[MedicineGroups].[MedicineGroupNa me]
FROM Medicines, MedicineGroups
WHERE Medicines.ID_ME DICINEGROUP = MedicineGroups. ID_MEDICINEGROU P;

and I tried something like
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE=" &
[ID_MEDICINE])
as the value of the edit box but another problem apperas - dlookup is
calculated once and all records have the same value in the edit box no
matter what ID.MEDICINE is (all fields have the value connected with the
ID.MEDICINE of the 1st record)

Any suggestions? I will be very very very grateful for any help since I am
out of ideas
Chris Bartosiewicz

Nov 13 '05 #4
Hmm.. It's not a problem any more :)
I struggled with that problem for a while and after I send the mail to the
newsgroup I realised how simple it was.. Finally I used the third option

The entry:
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE="
&[ID_MEDICINE])
was correct but it was misplaced - I used it in default value instead of the
source...

Sorry for bothering you..
Chris

Uzytkownik "Salad" <oi*@vinegar.co m> napisal w wiadomosci
news:N0******** *********@newsr ead1.news.pas.e arthlink.net...
Krzysztof Bartosiewicz wrote:
Hi!
I haven't been using Access for a very long time and I forgot everything
:) I will be very greatful for help since I have been fighting with this
problem for a few hours...

I have three tables: Medicines (ID_Medicine, ID_MedicineGrou p,
MedicineName), MedicineGroups (ID_MedicineGro up, MedicineGroupNa me) and
Treatment (ID_MEDICINE, ID_CONSULT, ID_COMMENT). After the user chooses
appropraite MedicineGroup and later Medicine from appropriate Combos I
add records to table. Then I must show all the records in a subform which
were added during current consultation with an ability to input Comment
regarding the usage of medicines. It would be no problem - simply display
all three fields (ID_MEDICINE, ID_CONSULT, ID_COMMENT) but the problem is
that I also need to display the names of the medicine and medicinegroup
which are in different table.


Here is an alternative method. In your main form, have the consult info.
In your subform, based on a table with the following fields, have the
fields ConsultID (to link), the MedicineGroup (combo), the MedicineID
(visible no), the MedicineName (a calced field that displays the medicine
name based on medicineID, and Comments.

In the AfterUpdate event of the MedicineGroup, call a form (modal) that
displays a listbox of all medicines for that medicine group. Provide a
Select and Cancel buttons. If a person dbl-clicks on a medicine in the
listbox for that group, or single clicks and presses the Select button,
that value is stored into the MedicineID field. If cancel, nothing.
Requery the calced medicine description field when the form is closed.
Also, allow the user to dbl-click on the description field to pull up the
list box (if a group has been selected). Now add the comments....or pull
the comments that may be contained in comments already created for that
medicine and allow additional comments to be made. This way the subform
can be continuous.

I tried 3 solutions:
1. When I simply changed source of the form to include other tables it
was not possible to edit the values (comments). I assume that it is as it
should be and there is no way to make Access display data from other
tables on the same form and change data in only one table?

2. When I tried to use a subform in a subform which shows me the names
everything is all right but unfortunately then I am not able to display
many medicines at once since it is only possible to show single record at
a time.

3. I also tried to use an editbox which should be somehow filled with a
text from a query. I created a query

SELECT [Medicines].[ID_MEDICINE], [Medicines].[MedicineName],
[MedicineGroups].[MedicineGroupNa me]
FROM Medicines, MedicineGroups
WHERE Medicines.ID_ME DICINEGROUP = MedicineGroups. ID_MEDICINEGROU P;

and I tried something like
=DLookUp("Medic ineGroupName";"[Query_Medicines]";"Medicines.ID _MEDICINE="
& [ID_MEDICINE])
as the value of the edit box but another problem apperas - dlookup is
calculated once and all records have the same value in the edit box no
matter what ID.MEDICINE is (all fields have the value connected with the
ID.MEDICINE of the 1st record)

Any suggestions? I will be very very very grateful for any help since I
am out of ideas
Chris Bartosiewicz

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3613
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any grid control. I tried many grid controls (DBGrid, DataGrid, MSFlexGrid), the ADO Data Control and everything I can think of, with no success. Here are the contraints I faced: (1) Populating any of the grid controls manually is too slow for my...
5
2226
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a printer-friendly report is not the best way to go. So, I tried converting one of my Access reports to an Access form. I selected the continuous view to allow displaying multple records but when I went to define my sorting and grouping there was none...
5
4005
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL 2000. Of course there were no modifications made to the queries and they noticed significant performance issues. They recently upgraded the application to Access XP expecting the newer version to provide performance benefits and now queries take...
0
1831
by: WindAndWaves | last post by:
Hi Gurus Here is another question that I have been struggling with for over a year. Basically, I would like to allow users to enter data into three tables in at the same time. The reason it should all be happening on one form is that the data comes in in chuncks and that the users do not like switching between windows (forms) too many times. To enter data into two tables (e.g. organisations and contacts) at the same
7
11835
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For tables that involve a number field as the primary key, the data is returned successfully. For tables that involve a character field (e.g. CHAR(3) or VARCHAR(10)) as the primary key, I have the correct number of rows returned, but the data displayed...
9
2359
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There is a Judge Table (information about judges) judgeID = autonumber key
3
3834
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
0
1514
by: latin & geek via DotNetMonster.com | last post by:
hi! ok, im working on a database application. ive successfully managed to establish a relationship between two tables and display them on a datagrid, edit and add new records to them. now i need to generate a report using the parameters in the child table, and two columns from the parent table. this is where the problem starts. when i use two seperate connection links and extract the required data, adding it all to the same dataset,...
1
7261
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan Muhammad. In some cases I’m trying to extend the examples. Currently, I have the following code to read data from a SQL Server 2005 database and display in a GridView:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.