I'm creatig a data base and in my front page i have 3 sub forms and 3 buttons for the sub forms to activate or not.
1. Subform1 is where all the current list of the patients being admitted for consultation. This form is Visible=True upon Form_Load().
2. Subform2 is where all the list of patient's name. This form is Visible=False upon Form_Load().
3. Subform3 displays the patient's personal information and the result entries (it is where the doctor encode their diagnosis, medications and laboratories). This form is Visible=False upon Form_Load().
I want to select a patient from subform1 linking the PatientID from the main form using the button3 and view it as a me.subform3.visible=True and me.subform1.Visible=False.
I have 2 option codes
First code : My problem on this code is that it will not work and no error messages.
Private Sub button3_Click()
Me.subform3.Visible = True
Dim varWhere As Variant
' Initialize to Null
varWhere = Null
' If specified a company name value
If Not IsNothing(Me.PatientID) Then
' .. build the predicate
varWhere = "[PatientID] LIKE '" & Me.PatientID & "*'"
End If
' Check to see that we built a filter
If IsNothing(varWhere) Then
MsgBox "Please select a patient.", vbInformation, gstrAppTitle
Exit Sub
End If
' See if any rows with a quick DLookup
If IsNothing(DLookup("PatientID", "Subform3Qry", varWhere)) Then
MsgBox "No Patient's last name meet your criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
Me.Subform3.Controls("PatientID") = varWhere
End Sub
Second Code: but if im going to use this, it will display an error saying "Run time error '2185': you connot reference aproperty or method for a control unless the control has the focus."
Private Sub button3_Click()
Me.subform3.Visible = True
Dim temp As String
temp = "*" & PatientID.Text & "*"
Me.subform3.Form.Filter = "PatientID like '" & temp & "'"
Me.subform3.Form.FilterOn = True
End Sub
thanks alot in advance for helping.