G
GaryZ
The The form called by DoCmd.OpenForm should stay focused until the user
closes that form via the X button after entering all proper Utility Names.
However, it immediately loses focus and the MsgBox pronmpt appears on top of
the open form. The MsgBox prompt has focus.
The form's Modal is "Yes". Allow Edits is "Yes"
Here is the entire procedure:
Private Sub CmdUpdUtilFld_Click()
' Create adodb recordset, connection and command here
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
' Try the following adodb connection
Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cnn
' Select Distinct Utility Field to create table Old-NewUtil
containing fields OldUtility and NewUtility
.CommandText = "SELECT DISTINCT [Utility] AS OldUtility, Space(60)
AS NewUtility INTO [Old-NewUtil] FROM [QA Follow-Up]"
.Execute
End With
Set cmd = Nothing
Set cnn = Nothing
'--- Here is the problem source code
'--- This DataSheet form has two columns. 1. A list of Utility Names, 2. An
empty
'--- field for entering the proper Utility Name. These are the fields from
'--- "Old-NewUtil" created in the above SQL.
'Open "Input New Utility Names" form in datasheet view and Edit mode in
order to input proper values into NewUtility field.
DoCmd.OpenForm "Input New Utility Names", acFormDS, , , acFormEdit
' Prompt to Update QA Follow-Up
Dim Prompt As String, Title As String, Response As Variant
Title = "Preparing to Update QA Follow-Up"
Prompt = "Do you want to Update the QA Follow-Up.Utility Field?"
'--- This MsgBox appears immediately on top of the DataSheet form. The
MsgBox has focus. It should not happen until the user closes the DataSheet
form.
Response = MsgBox(Prompt, vbInformation + vbYesNo, Title)
If Response = vbNo Then
Exit Sub
End If
Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
With cmd
'Update QA Follow-Up.Utility Field with new value
.CommandText = "UPDATE [QA Follow-Up] INNER JOIN [Old-NewUtil] ON
[QA Follow-Up].[Utility]=[Old-NewUtil].[oldUtility] SET [QA
Follow-Up].Utility = [Old-NewUtil].[NEWUtility];"
.Execute
End With
Set cmd = Nothing
Set cnn = Nothing
End Sub
closes that form via the X button after entering all proper Utility Names.
However, it immediately loses focus and the MsgBox pronmpt appears on top of
the open form. The MsgBox prompt has focus.
The form's Modal is "Yes". Allow Edits is "Yes"
Here is the entire procedure:
Private Sub CmdUpdUtilFld_Click()
' Create adodb recordset, connection and command here
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
' Try the following adodb connection
Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cnn
' Select Distinct Utility Field to create table Old-NewUtil
containing fields OldUtility and NewUtility
.CommandText = "SELECT DISTINCT [Utility] AS OldUtility, Space(60)
AS NewUtility INTO [Old-NewUtil] FROM [QA Follow-Up]"
.Execute
End With
Set cmd = Nothing
Set cnn = Nothing
'--- Here is the problem source code
'--- This DataSheet form has two columns. 1. A list of Utility Names, 2. An
empty
'--- field for entering the proper Utility Name. These are the fields from
'--- "Old-NewUtil" created in the above SQL.
'Open "Input New Utility Names" form in datasheet view and Edit mode in
order to input proper values into NewUtility field.
DoCmd.OpenForm "Input New Utility Names", acFormDS, , , acFormEdit
' Prompt to Update QA Follow-Up
Dim Prompt As String, Title As String, Response As Variant
Title = "Preparing to Update QA Follow-Up"
Prompt = "Do you want to Update the QA Follow-Up.Utility Field?"
'--- This MsgBox appears immediately on top of the DataSheet form. The
MsgBox has focus. It should not happen until the user closes the DataSheet
form.
Response = MsgBox(Prompt, vbInformation + vbYesNo, Title)
If Response = vbNo Then
Exit Sub
End If
Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
With cmd
'Update QA Follow-Up.Utility Field with new value
.CommandText = "UPDATE [QA Follow-Up] INNER JOIN [Old-NewUtil] ON
[QA Follow-Up].[Utility]=[Old-NewUtil].[oldUtility] SET [QA
Follow-Up].Utility = [Old-NewUtil].[NEWUtility];"
.Execute
End With
Set cmd = Nothing
Set cnn = Nothing
End Sub