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.