VB code help - It has been a long time (1 Viewer)

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Hi
This is my first post, I was once very proficient and knowledgeable about VB coding but I have not done any programming for the past 10 years. I have recently changed occupation and I’m going to be a manual therapist. I need to keep computerised records as I have sight issues and this is a much easier method for me to store them.
I have MS Access 2010+Windows 7, I’m having a few issues with certain tasks…
My database consists of 3 tables so far.
  • Patient Details – name, address, doctor’s name and address, tel etc….
  • Returns – contains details and notes about each visit
  • Presenting complaint/Medical History – Medical information, presenting complains etc.. this needs to be separate as if a patients returns 2 years after this initial consolation I would need to fill another one out, yet still have access to the original records.
Patient details has the primary key “Pt ID” which links to the other two tales in a field named Link ID.
I have 4 forms
  • Patient List – list of all patients that I can search to find the relevant data, within the list I have buttons to open forms for which contains the details relevant to that patient.
  • Patient Details
  • Returns
  • Medical History
Problem 1
I can create and save patient details in the patient details form, but when I select the Returns form from my Patient List form I get nothing appearing on my Returns form, no controls nothing (this form opens separately and contains Pt. ID, Name and a sub form which enables me to enter the Returns details) . If I manually open the returns Table and enter the Pt. ID value into the Link ID of the returns table, then the above process works fine.
So I want to add a button on my Patient Details form which will insert a new record into the Returns Tables and insert the primary key value of current Patient Details Table Pt ID into the Link ID of the Returns Table.
I hope this all makes sense :)
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Any1, I'm sure it's not that complicated!
 

JANR

Registered User.
Local time
Today, 10:47
Joined
Jan 21, 2009
Messages
1,623
Are you using Bound or Unbound forms?

JR
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Hi

If it helps, here is a link to the Access file

osteopathic-consent.com / Contacts4.accdb

Ive been makeing alterations to the Contacts database template that comes with Access 2010.
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Thanks :D

I'll give it a go over the weekend.

:)
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Ok the LinkMast is ID (PK from patient details table) and LInkChild is Link ID (FK from Returns table) on my retruns form.

This all works, only if the retrun table has a Link ID that matches the ID. With new patients who have not got a Link ID, it dosn't work.... the Form and Subform are both blank (as in you can't see them).
 

JANR

Registered User.
Local time
Today, 10:47
Joined
Jan 21, 2009
Messages
1,623
Yes that would be correct, no child records should exist without the parent record. That would leed to orphan records in you DB.

So for new patients you have to create a parent record before you create any child records.

JR
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
Yes that would be correct, no child records should exist without the parent record. That would leed to orphan records in you DB.

So for new patients you have to create a parent record before you create any child records.

JR

But the parent record is there.... I have a patient with a patient "ID" of 5 within the main "Patient Details Table". But the returns table has no "Link ID" of 5. So when I go into patient 5's details and look at the "Retruns form", it is blank (no form, no text boxes, nothing).

If I open the returns table up directly and add a new record and input the LINK ID as 5, it will then work. But obviously I do not want to have to do this manually?
 

G man

New member
Local time
Today, 01:47
Joined
May 5, 2011
Messages
7
I'm guessing what I need is a small ammount of code?

When I add new patient details and then click "Save" this all works fine. But when I click save I need to copy the new patients PK "ID" from the Patients Details Table into the FK Link ID in the Returns Table. So that when I open the Returns Form there is a blank record ready and waiting with the correct LInk ID.
 

Users who are viewing this thread

Top Bottom