move between forms for the same ID

G

Guest

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks
 
G

Guest

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

Sprinks said:
Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

smccullough said:
I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

smccullough said:
This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

Sprinks said:
Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

smccullough said:
I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


Sprinks said:
Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

smccullough said:
This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

Sprinks said:
Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

smccullough said:
Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


Sprinks said:
Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

smccullough said:
This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

Sprinks said:
Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

smccullough said:
Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


Sprinks said:
Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

What is the name of the button that's not working? If it is Command88, it's
not working because you haven't assigned stLinkCriteria, as you do in the
others:

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"

If you can't get it to work, delete the button, toggle the wizard on (View,
Toolbox, depress the wand with stars button), and add a new one to open a
form with specific data to view. The wizard will take care of the rest.

Hope that helps.
Sprinks

smccullough said:
I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

Sprinks said:
Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

smccullough said:
Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


:

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

Man do I wish I had been able to get back here the other week. Thank you. I
have taken out my command buttons and have done new ones, it works
beautifully. I knew there had to be a simple way to do this.

The next thing I would like to do is edit a form that I have for
medications. I have check boxes beside types of meds. I would like to have
a list of drugs and dosages pop up when one or more of the boxes is checked.
I also need to be able to have the drugs and dosages show up on queries.

Can you help with this too?

Shirley McCullough



Sprinks said:
What is the name of the button that's not working? If it is Command88, it's
not working because you haven't assigned stLinkCriteria, as you do in the
others:

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"

If you can't get it to work, delete the button, toggle the wizard on (View,
Toolbox, depress the wand with stars button), and add a new one to open a
form with specific data to view. The wizard will take care of the rest.

Hope that helps.
Sprinks

smccullough said:
I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

Sprinks said:
Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

:


Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


:

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

This is working for editing, is there something different that I need to do
to be able to do "new" data entry? When I attempted to enter a new patient,
I came up with the same problem as before, I am not at a screen with the new
aptient ID I am at some other patient ID.

smccullough said:
Man do I wish I had been able to get back here the other week. Thank you. I
have taken out my command buttons and have done new ones, it works
beautifully. I knew there had to be a simple way to do this.

The next thing I would like to do is edit a form that I have for
medications. I have check boxes beside types of meds. I would like to have
a list of drugs and dosages pop up when one or more of the boxes is checked.
I also need to be able to have the drugs and dosages show up on queries.

Can you help with this too?

Shirley McCullough



Sprinks said:
What is the name of the button that's not working? If it is Command88, it's
not working because you haven't assigned stLinkCriteria, as you do in the
others:

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"

If you can't get it to work, delete the button, toggle the wizard on (View,
Toolbox, depress the wand with stars button), and add a new one to open a
form with specific data to view. The wizard will take care of the rest.

Hope that helps.
Sprinks

smccullough said:
I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

:

Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

:


Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


:

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

I'm not sure I'm following; you tell me if I've got it.

You enter basic patient information into some table on some form. From this
form, you might launch other forms where you enter other data related to that
patient, such as medications & dosages, and others. You launch these with a
command button that uses stLinkCriteria to go to the correct record in the
RecordSource of the 2nd form.

If no corresponding record exists in the table underlying the 2nd form, it
should put you at a blank record, NOT another patient's record. If it's
doing that, your command button procedure must not be assigning
stLinkCriteria. Cut and paste it if you like.

In any case, if you arrive at a blank record, you could have the OnOpen
event procedure set the PatientID and move to the next field for adding a new
one:

If IsNull([PatientID]) Then
[PatientID] = Me!Forms![YourPreviousForm]![PatientID]
End If
[YourNextControl].Setfocus

Note that I've *assumed* that the name of the control on both forms is
PatientID. Change as appropriate.

Regarding the checkbox issue, is there a reason you wish to have a finite
number of checkboxes rather than a single combo box for "Meds Type"?

But, I'll assume for the moment that you have a good reason. Next to each
check box, you could provide combo boxes for the Meds and Dosages. Each Meds
combo box would have the same basic RowSource, i.e.,

SELECT Meds.MedID, Meds.MedName FROM Meds

but would have a differing WHERE clause that selected only that type:

WHERE Meds.MedType = 1

Does this make sense?

In the AfterUpdate event procedure, you could enable or disable the combo
boxes as appropriate:

If Me!MyCheckbox = True Then
Me!MyMedsCombo.Enabled = True
Me!MyDosageCombo.Enabled = True
Else
Me!MyMedsCombo.Enabled = False
Me!MyDosageCombo.Enabled = False
End If

Hope that helps.
Sprinks


smccullough said:
This is working for editing, is there something different that I need to do
to be able to do "new" data entry? When I attempted to enter a new patient,
I came up with the same problem as before, I am not at a screen with the new
aptient ID I am at some other patient ID.

smccullough said:
Man do I wish I had been able to get back here the other week. Thank you. I
have taken out my command buttons and have done new ones, it works
beautifully. I knew there had to be a simple way to do this.

The next thing I would like to do is edit a form that I have for
medications. I have check boxes beside types of meds. I would like to have
a list of drugs and dosages pop up when one or more of the boxes is checked.
I also need to be able to have the drugs and dosages show up on queries.

Can you help with this too?

Shirley McCullough



Sprinks said:
What is the name of the button that's not working? If it is Command88, it's
not working because you haven't assigned stLinkCriteria, as you do in the
others:

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"

If you can't get it to work, delete the button, toggle the wizard on (View,
Toolbox, depress the wand with stars button), and add a new one to open a
form with specific data to view. The wizard will take care of the rest.

Hope that helps.
Sprinks

:

I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

:

Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

:


Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


:

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 
G

Guest

You got it. I will follow these and let you know how it works.

Thank you once again.

Sprinks said:
I'm not sure I'm following; you tell me if I've got it.

You enter basic patient information into some table on some form. From this
form, you might launch other forms where you enter other data related to that
patient, such as medications & dosages, and others. You launch these with a
command button that uses stLinkCriteria to go to the correct record in the
RecordSource of the 2nd form.

If no corresponding record exists in the table underlying the 2nd form, it
should put you at a blank record, NOT another patient's record. If it's
doing that, your command button procedure must not be assigning
stLinkCriteria. Cut and paste it if you like.

In any case, if you arrive at a blank record, you could have the OnOpen
event procedure set the PatientID and move to the next field for adding a new
one:

If IsNull([PatientID]) Then
[PatientID] = Me!Forms![YourPreviousForm]![PatientID]
End If
[YourNextControl].Setfocus

Note that I've *assumed* that the name of the control on both forms is
PatientID. Change as appropriate.

Regarding the checkbox issue, is there a reason you wish to have a finite
number of checkboxes rather than a single combo box for "Meds Type"?

But, I'll assume for the moment that you have a good reason. Next to each
check box, you could provide combo boxes for the Meds and Dosages. Each Meds
combo box would have the same basic RowSource, i.e.,

SELECT Meds.MedID, Meds.MedName FROM Meds

but would have a differing WHERE clause that selected only that type:

WHERE Meds.MedType = 1

Does this make sense?

In the AfterUpdate event procedure, you could enable or disable the combo
boxes as appropriate:

If Me!MyCheckbox = True Then
Me!MyMedsCombo.Enabled = True
Me!MyDosageCombo.Enabled = True
Else
Me!MyMedsCombo.Enabled = False
Me!MyDosageCombo.Enabled = False
End If

Hope that helps.
Sprinks


smccullough said:
This is working for editing, is there something different that I need to do
to be able to do "new" data entry? When I attempted to enter a new patient,
I came up with the same problem as before, I am not at a screen with the new
aptient ID I am at some other patient ID.

smccullough said:
Man do I wish I had been able to get back here the other week. Thank you. I
have taken out my command buttons and have done new ones, it works
beautifully. I knew there had to be a simple way to do this.

The next thing I would like to do is edit a form that I have for
medications. I have check boxes beside types of meds. I would like to have
a list of drugs and dosages pop up when one or more of the boxes is checked.
I also need to be able to have the drugs and dosages show up on queries.

Can you help with this too?

Shirley McCullough



:

What is the name of the button that's not working? If it is Command88, it's
not working because you haven't assigned stLinkCriteria, as you do in the
others:

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"

If you can't get it to work, delete the button, toggle the wizard on (View,
Toolbox, depress the wand with stars button), and add a new one to open a
form with specific data to view. The wizard will take care of the rest.

Hope that helps.
Sprinks

:

I have found one of the problems. As data is entered, if a patient does not
have information to be logged on a form, such as if the Medical History does
not include one of the illnesses on the list then that patient's ID is not
recorded on the medical history table. So I need to fix that, then I still,
even when the ID I am on in the Demographic form is in the medical history
and I click the go to command - I go to the correct form, BUT I go to the
first record of that form - NOT the record that cooresponds to the patient I
am editing.

:

Hi.

The syntax of the procedures for Command 96 and 97 look correct, assuming
the name of your second form is Medical History. They and Command88 seem to
be duplicates of each other, however. More importantly, the procedure for
Command88, however, never assigns a value to stLinkCriteria. Is this the
button you're pushing?

Hope that helps.
Sprinks

:


Private Sub Current_Age_Change()
=Age([DateofBirth]) & " yrs "
End Sub
Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
MsgBox Err.Description
Resume Exit_Command88_Click

End Sub
Private Sub Look_up_Patient_ID_Click()
On Error GoTo Err_Look_up_Patient_ID_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Look_up_Patient_ID_Click:
Exit Sub

Err_Look_up_Patient_ID_Click:
MsgBox Err.Description
Resume Exit_Look_up_Patient_ID_Click

End Sub
Private Sub Command96_Click()
On Error GoTo Err_Command96_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command96_Click:
Exit Sub

Err_Command96_Click:
MsgBox Err.Description
Resume Exit_Command96_Click

End Sub
Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Medical History"

stLinkCriteria = "[PatientID]=" & "'" & Me![PatientID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command97_Click:
Exit Sub

Err_Command97_Click:
MsgBox Err.Description
Resume Exit_Command97_Click

End Sub


:

Something in the references to the control on the current form or the name of
the field in the RecordSource of the second form is amiss. Please cut &
paste (don't attempt to retype it) your entire command button event procedure
& I'll see if I can figure it out.

Sprinks

:

This didn't quite make it. A bit more detail. I have a patient database. I
have a table named patient Demograpic data and the next table is named
medical history. The index key for each of these tables is the patient ID,
which is just a four digit serial number. When I enter data for 0212 in demo
form, and clicked the command button to go to medical history, it moved
forward but to ID 0003.

I took out my command button and followed you instructions and I eneded up
with a blank medical history form labeled as patient 0001.

I need 0212 demo data to link with 0212 medical history.

Can you help :)

:

Hi.

You need to use a Where clause in the OpenForm statement. The command
button wizard will add this automatically if you choose the option "Open the
form and find specific data to display".

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewFormName"

stLinkCriteria = "[LinkField]=" &
Me![ControlOnCurrentFormContainingLinkField]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you wish to close the first form, add the code:

DoCmd.Close acForm, "YourFirstFormName", acSaveYes

Hope that helps.
Sprinks

:

I have a patient database with multiple tables, each table contains part of
the information for each patient. I have forms setup for dataentry with
command buttons to move from one form to another. The Issue is when I move
from one form to another, I am NOT looking at the same patient that I started
with.
 

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