G
Gnerks
I have a main form (AEF) with a combo box (cboAFSselect), a text box
(txtAFS), and a command button (cmdGoToM4). The main form retrieves distinct
row information from the user selection and puts it in the text box. Then
the user presses the command button and what I want is the subform
frmM4Included to show matching AFS information (parent link and child link
are the field AFS). Originally I had this information linking correctly in
separate forms. I just need to get them to work on the same form (main/sub).
How do I get that to happen? My code follows:
Option Compare Database
Option Explicit
Function IsLoaded(ByVal strFormName As String) As Integer
'Returns true if the specified form is open in Form view or Datasheet view
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Form(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
Private Sub cboAFSselect_AfterUpdate()
Me!txtAFS = Me!cboAFSselect.Column(1)
End Sub
Private Sub cmdGoToM4_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim Msg, Style, Title, Response
stDocName = "frmM4"
stLinkCriteria = "[AFS]=" & "'" & Me![cboAFSselect] & "'"
If Not IsNull(stLinkCriteria) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Else
Msg = "Manfor does not have UTC information for this AFS. Please select
another AFS!"
Style = vbOKOnly
Title = "MANFOR"
Response = MsgBox(Msg, Style, Title)
End If
End Sub
And, if that is not enough, how do I get the message box to appear in the
subform when there is not a match for AFS between the Main and Subforms?
Any assistance is greatly appreciated.
(txtAFS), and a command button (cmdGoToM4). The main form retrieves distinct
row information from the user selection and puts it in the text box. Then
the user presses the command button and what I want is the subform
frmM4Included to show matching AFS information (parent link and child link
are the field AFS). Originally I had this information linking correctly in
separate forms. I just need to get them to work on the same form (main/sub).
How do I get that to happen? My code follows:
Option Compare Database
Option Explicit
Function IsLoaded(ByVal strFormName As String) As Integer
'Returns true if the specified form is open in Form view or Datasheet view
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Form(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
Private Sub cboAFSselect_AfterUpdate()
Me!txtAFS = Me!cboAFSselect.Column(1)
End Sub
Private Sub cmdGoToM4_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim Msg, Style, Title, Response
stDocName = "frmM4"
stLinkCriteria = "[AFS]=" & "'" & Me![cboAFSselect] & "'"
If Not IsNull(stLinkCriteria) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Else
Msg = "Manfor does not have UTC information for this AFS. Please select
another AFS!"
Style = vbOKOnly
Title = "MANFOR"
Response = MsgBox(Msg, Style, Title)
End If
End Sub
And, if that is not enough, how do I get the message box to appear in the
subform when there is not a match for AFS between the Main and Subforms?
Any assistance is greatly appreciated.