francesyang
Programmer
Thanks in advanced if anyone can help me out ASAP.
My intend is to click AddLab button from the form frm_searchPatient, then open the form frm_Labs to add additional information to current PatID. The problem is that the key, PatID, doesn't get passed to the frm_Labs.
Access VB code of frm_searchpatient is the following:
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Private Sub PatID_Combo_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PatID] = '" & Me![PatID_Combo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Private Sub addLabs_Click()
On Error GoTo Err_AddLabs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Labs"
' Open Labs form in data entry mode and store PatientID in
' the form's OpenArgs property.
stLinkCriteria = "[PatID]=" & "'" & Me![PatID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Close Labs form.
'DoCmd.Close acForm, "frm_Labs"
' Give data entry control focus.
Forms![frm_Labs]!SpecNum.SetFocus
Exit_AddLabs_Click:
Exit Sub
Err_AddLabs_Click:
MsgBox Err.Description
Resume Exit_AddLabs_Click
End Sub
Private Sub Form_Current()
On Error GoTo Err_Form_Current
' If the Labs form is open, show current supplier's products.
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "frm_labs"
strLinkCriteria = "[PatID] = Forms![Labs]![PatID]"
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
VB code for frm_Labs:
Private Sub PatID_AfterUpdate()
' If OpenArgs property isn't null, set PatID to value of form's OpenArgs
' property. OpenArgs will have a value if Labs form is opened by clicking
' AddLabs command button on Labs form.
If IsNull(Forms!Labs.OpenArgs) Then
Exit Sub
Else
Me!PatID = Forms!Labs.OpenArgs
End If
End Sub
Private Sub Form_Current()
On Error GoTo Err_Form_Current
' If the Labs form is open, show current PatID.
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "frm_labs"
strLinkCriteria = "[PatID] = Forms![Labs]![PatID]"
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
My intend is to click AddLab button from the form frm_searchPatient, then open the form frm_Labs to add additional information to current PatID. The problem is that the key, PatID, doesn't get passed to the frm_Labs.
Access VB code of frm_searchpatient is the following:
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Private Sub PatID_Combo_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PatID] = '" & Me![PatID_Combo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Private Sub addLabs_Click()
On Error GoTo Err_AddLabs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Labs"
' Open Labs form in data entry mode and store PatientID in
' the form's OpenArgs property.
stLinkCriteria = "[PatID]=" & "'" & Me![PatID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Close Labs form.
'DoCmd.Close acForm, "frm_Labs"
' Give data entry control focus.
Forms![frm_Labs]!SpecNum.SetFocus
Exit_AddLabs_Click:
Exit Sub
Err_AddLabs_Click:
MsgBox Err.Description
Resume Exit_AddLabs_Click
End Sub
Private Sub Form_Current()
On Error GoTo Err_Form_Current
' If the Labs form is open, show current supplier's products.
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "frm_labs"
strLinkCriteria = "[PatID] = Forms![Labs]![PatID]"
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
VB code for frm_Labs:
Private Sub PatID_AfterUpdate()
' If OpenArgs property isn't null, set PatID to value of form's OpenArgs
' property. OpenArgs will have a value if Labs form is opened by clicking
' AddLabs command button on Labs form.
If IsNull(Forms!Labs.OpenArgs) Then
Exit Sub
Else
Me!PatID = Forms!Labs.OpenArgs
End If
End Sub
Private Sub Form_Current()
On Error GoTo Err_Form_Current
' If the Labs form is open, show current PatID.
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "frm_labs"
strLinkCriteria = "[PatID] = Forms![Labs]![PatID]"
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub