473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SQL to show records from 2 tables in single listbox

Hey guys,
I'm sure there's something really simple I'm overlooking here, so I'm hoping someone more learned will be able to point me in the right direction.

Here's what I've got:
When a patient fills out an initial visit form (which corresponds with TblInitialForm, primary key is ID), their surgial and non-surgical plans are recorded in two separate tables, TblSurgPlan and TblNonSurgPlan. The primary key for both tables are ID (which is linked to the initial form ID, and ListID, which is 1,2,3, etc. based on the order in which they were added.) The plans are recorded as text in SurgPlanString and NonSurgPlanString. Right now, both tables are shown in 2 separate listboxes... This looks really awkward though, so I was wondering about the steps I would take in the rowsource of the listbox if I wanted to display both tables in the same one.

This is the current SQL I have in one of my listboxes:


Expand|Select|Wrap|Line Numbers
  1. SELECT TblInitialNonSurgPlan.NonSurgPlanString
  2. FROM TblInitialNonSurgPlan
  3. WHERE (((TblInitialNonSurgPlan.ID)=[Forms]![FrmInitialForm].[ID]))
  4. ORDER BY TblInitialNonSurgPlan.ListID;

Right now the bound column is set to ListID, but if I were to combine them, I could switch the bound column to the text field, because that would not be the same in either table.

Any advice on how to approach this in SQL? I'm stumped and don't know where to start!

Thanks!!
May 5 '11 #1
1 1530
Rabbit
12,516 Expert Mod 8TB
Use an inner join to join both tables. To display both fields in the listbox, you would just need to concatenate the two fields together, probably with some sort of delimiter.
May 5 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fatou | last post by:
I have a listbox where the user selects only one value at a time. The problem is that once the user selects the value and the record is updated in the table, they can reselect the same value...
3
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data...
2
by: Gordon | last post by:
Hi; I am a novice asp.net developer who would like to create a dataset-table and then use the datatable.select cmd. to look up a value passed from the web calender control. The value(s) would...
15
by: Joachim | last post by:
Hi, Als a beginner, I am looking for a way to show records My code is Private sub Connection( Dim odbconn_Pro As OleDbConnectio Dim odbcomm_Pro As OleDbComman Dim odbdare_Pro As...
1
by: Stefan van Roosmalen | last post by:
Hi there, Is there a way to list the TEMPORATY tables? I have tried SHOW TABLES, but this command only list the regular tables. Thank you very much for your answer. Regards, Stefan.
3
by: tushar jadhav | last post by:
Suppose, i hv an 10 columns and next to that other columns in a DB Table. That 10 columns hv same default values & others are retriving from other table and are nearly 1000 records. How can i insert...
1
by: Steve | last post by:
I have to tables Table1 IMS_ID IMS_Name IMS_Descript Table2 P_IMS_ID P_IMS_Name P_IMS_Descript
0
by: CoreyReynolds | last post by:
Hello all! Thanks everyone for the great help you've given me so far on this forum - I have another intermediate question. I currently have a form where a user chooses a piece of equipment,...
2
Daniel B
by: Daniel B | last post by:
I have a subform that displays records of information. When a new record is created and saved, the record will appear in the tables, but not in the subform. It seems that when I fill in...
1
by: brin | last post by:
Hello Experts. I need a help plz. i got a database with tables: daily sales, payments, banking etc... all i want to do is, create one single report with list of seven days taking and payments. im...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.