Subform Difficulty

B

BlakeD

I have four tables in my database:
tblClients: RecordID (PK), FName, LName, DoB, Gender(FK), etc.
tblServices: Svc_Code (PK), Descrip, Require_ClientID(Boolean),
Allow_Multi_Client(Boolean)
tblTreatments: TXID (PK), TX_Counselor (FK), TX_SVCCode (FK),
TX_Duration (FK), TX_Date, TX_Start_Time, TX_Finish_Time
tbl_ClientSessions: TX_Session (PK), RecordID (PK) (Both are foreign
keys from tblTreatments and tblClients respectively)

I have a main form that will record a treatment:
"SELECT tblTreatments.TXID, tblTreatments.TX_Counselor,
tblTreatments.TX_SVCCode, tblTreatments.TX_Duration,
tblTreatments.TX_Date, tblTreatments.TX_Start_Time,
tblTreatments.TX_Finish_Time, tblServices.Require_ClientID,
tblServices.Allow_Multi_Client
FROM tblServices INNER JOIN (tblEmployees INNER JOIN (tblDurations
INNER JOIN tblTreatments ON tblDurations.DurationTime =
tblTreatments.TX_Duration) ON tblEmployees.EMPLOYEE_GUID =
tblTreatments.TX_Counselor) ON tblServices.Svc_Code =
tblTreatments.TX_Type
WHERE (((tblEmployees.ACTIVE)=-1));"

If the record is new, and the Require_ClientID is True, then I have two
subforms that appear and are enabled.

Subform Client_Selection_Subform
"SELECT tbl_ClientSession.TX_Session, tbl_ClientSession.TX_Client FROM
tbl_ClientSession;"
Link Child Fields: TX_Session
Link Master Fields: TXID
Allow Filters = True
Single Form View

On this subform is a listbox that I want to list all the clients from
tblClients.
TX_Client_Listbx
SELECT tblClients.RECORDID, tblClients.CLIENTID, tblClients.LName,
tblClients.FName, tblClients.GENDER, tblClients.TRIBE, tblClients.[PRIM
DRUG], tblClients.POLYSUB, tblClients.SMOKER, tblClients.EDUCATION,
tblClients.EMPLOYMENT, tblClients.APPSTAT, tblClients.[ADMISSION DATE],
tblClients.COUNSELOR, tblClients.[TX COMPLETE], tblClients.[DISCHARGE
DATE], tblClients.[FROM DETOXX], tblClients.BHB
FROM tblClients
ORDER BY tblClients.LNAME, tblClients.FNAME;

I want to be able to apply filters so I can weed down to just males, or
by who their counselor was, or etc. This subform should list all
clients (save for the effects of filters) and allow someone to link the
Treatment Session(TXID) to the Client's RecordID and record it in
tbl_Client-Sessions.

The second subform, Clients_Linked_Subform, should list all client
RecordID's already linked to the Treatment.TXID.
"SELECT tblClients.CLIENTID, tblClients.LName, tblClients.FName FROM
tblClients INNER JOIN tbl_ClientSession ON tblClients.RECORDID =
tbl_ClientSession.TX_Client;"
Link Child Fields: TX_Session
Link Master Fields: TXID
Allow Filters = True
Single Form View

Again, it uses a listbox to display the linked records:
"SELECT sqryLinkedSessions.[RECORD ID], sqryLinkedSessions.TX_Session,
sqryLinkedSessions.LName, sqryLinkedSessions.FName,
sqryLinkedSessions.CLIENTID FROM sqryLinkedSessions ORDER BY LName,
FName;"

sqryLinkedSessions is:
"SELECT tblClients.RECORDID, TBL_CLIENTSESSION.TX_Session,
tblClients.LName, tblClients.FName, tblClients.CLIENTID
FROM tblClients INNER JOIN TBL_CLIENTSESSION ON
tblClients.RECORDID=TBL_CLIENTSESSION.TX_Client
ORDER BY tblClients.LName;"


I'm having trouble on two fronts right now:
1) I can't get the first subform to save records to the
tbl_ClientSessions table.
2) When I click on any controls in the first subform, I get errors.
When I click the Listbox of clients, I get "User-Defined type not
defined". If I click on one of the controls I'm making to help filter
the listbox, I get "The expression On Click you entered as the event
property setting produced the following error: User-defined type not
defined."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top