G
Gnerks
I have 2 forms. The first has a combo box the user uses to select an AFS
(field) and a command button to go to the next form. The command button was
set up via the Command Button Wizard for Form Operations - Open Form - Open
and find specific data to display. With the specific data being the AFS
selected on form 1 matching (if it exists) on form 2. If it doesn't exist, I
want a message box to come up that says "There is no matching AFS in this
form" vbOKOnly and then allow the user to select another AFS. The code
generated by using the Command Button Wizard is as follows. Where I I insert
the MsgBox call?
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 Forms(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 cmdM4Details1_Click()
On Error GoTo Err_cmdM4Details1_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
stDocName = "frmM4_Details_PAM"
stLinkCriteria = "[AFS]=" & "'" & Me![cboAFSselect] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'If stLinkCriteria <> "[AFS]=" & "'" & Me![cboAFSselect] & "'" then
'Msg = "Manfor does not have a UTC for this AFS. Do you want to
continue ?" ' Define message.
'Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
'Title = "No MANFOR UTC" ' Define title.
'Help = "DEMO.HLP" ' Define Help file.
'Ctxt = 1000 ' Define topic
' context.
' Display message.
'Response = MsgBox(Msg, Style, Title, Help, Ctxt)
'If Response = vbYes Then ' User chose Yes.
' MyString = "Yes" ' Perform some action.
'Else ' User chose No.
' MyString = "No" ' Perform some action.
'End If
'End If
Exit_cmdM4Details1_Click:
Exit Sub
Err_cmdM4Details1_Click:
MsgBox Err.Description
Resume Exit_cmdM4Details1_Click
End Sub
(field) and a command button to go to the next form. The command button was
set up via the Command Button Wizard for Form Operations - Open Form - Open
and find specific data to display. With the specific data being the AFS
selected on form 1 matching (if it exists) on form 2. If it doesn't exist, I
want a message box to come up that says "There is no matching AFS in this
form" vbOKOnly and then allow the user to select another AFS. The code
generated by using the Command Button Wizard is as follows. Where I I insert
the MsgBox call?
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 Forms(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 cmdM4Details1_Click()
On Error GoTo Err_cmdM4Details1_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
stDocName = "frmM4_Details_PAM"
stLinkCriteria = "[AFS]=" & "'" & Me![cboAFSselect] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'If stLinkCriteria <> "[AFS]=" & "'" & Me![cboAFSselect] & "'" then
'Msg = "Manfor does not have a UTC for this AFS. Do you want to
continue ?" ' Define message.
'Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
'Title = "No MANFOR UTC" ' Define title.
'Help = "DEMO.HLP" ' Define Help file.
'Ctxt = 1000 ' Define topic
' context.
' Display message.
'Response = MsgBox(Msg, Style, Title, Help, Ctxt)
'If Response = vbYes Then ' User chose Yes.
' MyString = "Yes" ' Perform some action.
'Else ' User chose No.
' MyString = "No" ' Perform some action.
'End If
'End If
Exit_cmdM4Details1_Click:
Exit Sub
Err_cmdM4Details1_Click:
MsgBox Err.Description
Resume Exit_cmdM4Details1_Click
End Sub