Hello, all!
On an Access 2007 db (accdb) I have a split form (popup = no, modal = yes) that shows only the header and the datasheet portion (detail.visible = no). On the header portion, I have an unbound combobox, a textbox and two buttons 1) Tag and 2) Cancel.
The intended functionality is:
A) For existing tags (no problem with this part)
1) The user picks a tag from the combobox list
2) The text box receives the correspondent description for that tag
3) The user than clicks Tag to tag the records displayed on the datasheet portion (which were previously chosen on another form. The routine to tag the forms is not included below)
3a) or The user changes his / her mind and click Cancel, the records are not tagged and the form is closed.
B) If the user enters a value that is not in list for the combo
1) The NotInList events fires up
2) A new form is displayed (Popup = yes, modal = yes, Cycle = current record, Data Entry = Yes, Allow Additions = Yes, acformadd, acdialog, OpenArgs = NewData). The for has two text boxes and a two buttons.
3) After being opened, one of the form’s text boxes value is set to OpenArgs (NewData) and the focus is moved to the other text box so the user can enter the description
4) After the description input, the user should select Confirm , to create a new tag (THE PROBLEM HAPPENS HERE)
4a)or Cancel if the user changes his / her mind.
All should be pretty simple; however, when the user selects the Confirm button the NotInList event on the other form is activated again!!!!! I mean, instead of returning to the previous form code immediately after the OpenForm command, which I though it would be the case using acDialog. Therefore, the user receives the “Not in list, add it” message again, and the application tries to open the data entry form again, etc.
Naturally, this is not the expected behavior.
I bet is something stupid, but I can’t see it. Suggestions?
The code is below.
Form 1)
Private Sub cbx_TagDescription_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cbx_TagDescription_NotInList
Dim strSQL As String
Dim rstTagsDescriptions As ADODB.Recordset
Dim cnnTableConnection As ADODB.Connection
Dim intTagTooLong As Integer
If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then
DoCmd.OpenForm "frm_Tag_Observation_DataEntry", , , , DataMode:=acFormAdd, windowmode:=acDialog, OpenArgs:=NewData
intTagTooLong = MsgBox("Control Again on combo", vbCritical)
If Not IsNull(cbx_TagDescription.Value) Then
'If User confirmed the new data entry on form "frm_TagsObservations_DataEntry"
'then changes to "cbx_TagDescription" source should be confirmed
Response = acDataErrAdded
Me.txt_AccountComment.SetFocus
Else
'If User canceled the new data entry on form "frm_TagsObservations_DataEntry"
'then changes to "cbx_TagDescription" were canceled (undo)
'With changes to the combo box source canceled then the warning of "not in list" is to be supressed
Response = acDataErrContinue
End If
Else
Response = acDataErrContinue 'cancel changes to combo box source
Me.cbx_TagDescription.Undo
End If
Exit_cbx_TagDescription_NotInList:
Exit Sub
Err_cbx_TagDescription_NotInList:
MsgBox Err.Description
Resume Exit_cbx_TagDescription_NotInList
End Sub
Form 2)
Private Sub Form_Load()
On Error GoTo Err_Form_Load
If Me.DataEntry And Not (IsNull(Me.OpenArgs)) Then
Me.txt_TagDescription = Me.OpenArgs
End If
Me.txt_Observation.SetFocus
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub
Private Sub cmd_Confirm_Click()
Dim intObservationIsEmpty As Integer
If IsNull(Me.txt_Observation) Or Len(Me.txt_Observation) < 1 Then
intObservationIsEmpty = MsgBox("Please complete Observation for Tag before Confirming or Cancel!", vbCritical, "Observation is empty!!!")
Me.txt_Observation.SetFocus
Else
Me.Dirty = False (HERE IS WHERE THE "NotInList" EVENT IS FIRED AGAIN)
DoCmd.Close
End If
End Sub
Private Sub cmd_Cancel_Click()
On Error GoTo Err_cmd_Cancel_Click
Me.Undo
Me.Dirty = False
Forms!frm_Tag_Observation_Selection.Form![cbx_TagDescription].Undo
DoCmd.Close
Exit_cmd_Cancel_Click:
Exit Sub
Err_cmd_Cancel_Click:
MsgBox Err.Description
Resume Exit_cmd_Cancel_Click
End Sub
Any help is always apreciated!
Thx,
4N6MSTR
______________________________________________
If you don't know where you are going
It does not matter how fast you are
You will never get there
On an Access 2007 db (accdb) I have a split form (popup = no, modal = yes) that shows only the header and the datasheet portion (detail.visible = no). On the header portion, I have an unbound combobox, a textbox and two buttons 1) Tag and 2) Cancel.
The intended functionality is:
A) For existing tags (no problem with this part)
1) The user picks a tag from the combobox list
2) The text box receives the correspondent description for that tag
3) The user than clicks Tag to tag the records displayed on the datasheet portion (which were previously chosen on another form. The routine to tag the forms is not included below)
3a) or The user changes his / her mind and click Cancel, the records are not tagged and the form is closed.
B) If the user enters a value that is not in list for the combo
1) The NotInList events fires up
2) A new form is displayed (Popup = yes, modal = yes, Cycle = current record, Data Entry = Yes, Allow Additions = Yes, acformadd, acdialog, OpenArgs = NewData). The for has two text boxes and a two buttons.
3) After being opened, one of the form’s text boxes value is set to OpenArgs (NewData) and the focus is moved to the other text box so the user can enter the description
4) After the description input, the user should select Confirm , to create a new tag (THE PROBLEM HAPPENS HERE)
4a)or Cancel if the user changes his / her mind.
All should be pretty simple; however, when the user selects the Confirm button the NotInList event on the other form is activated again!!!!! I mean, instead of returning to the previous form code immediately after the OpenForm command, which I though it would be the case using acDialog. Therefore, the user receives the “Not in list, add it” message again, and the application tries to open the data entry form again, etc.
Naturally, this is not the expected behavior.
I bet is something stupid, but I can’t see it. Suggestions?
The code is below.
Form 1)
Private Sub cbx_TagDescription_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cbx_TagDescription_NotInList
Dim strSQL As String
Dim rstTagsDescriptions As ADODB.Recordset
Dim cnnTableConnection As ADODB.Connection
Dim intTagTooLong As Integer
If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then
DoCmd.OpenForm "frm_Tag_Observation_DataEntry", , , , DataMode:=acFormAdd, windowmode:=acDialog, OpenArgs:=NewData
intTagTooLong = MsgBox("Control Again on combo", vbCritical)
If Not IsNull(cbx_TagDescription.Value) Then
'If User confirmed the new data entry on form "frm_TagsObservations_DataEntry"
'then changes to "cbx_TagDescription" source should be confirmed
Response = acDataErrAdded
Me.txt_AccountComment.SetFocus
Else
'If User canceled the new data entry on form "frm_TagsObservations_DataEntry"
'then changes to "cbx_TagDescription" were canceled (undo)
'With changes to the combo box source canceled then the warning of "not in list" is to be supressed
Response = acDataErrContinue
End If
Else
Response = acDataErrContinue 'cancel changes to combo box source
Me.cbx_TagDescription.Undo
End If
Exit_cbx_TagDescription_NotInList:
Exit Sub
Err_cbx_TagDescription_NotInList:
MsgBox Err.Description
Resume Exit_cbx_TagDescription_NotInList
End Sub
Form 2)
Private Sub Form_Load()
On Error GoTo Err_Form_Load
If Me.DataEntry And Not (IsNull(Me.OpenArgs)) Then
Me.txt_TagDescription = Me.OpenArgs
End If
Me.txt_Observation.SetFocus
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub
Private Sub cmd_Confirm_Click()
Dim intObservationIsEmpty As Integer
If IsNull(Me.txt_Observation) Or Len(Me.txt_Observation) < 1 Then
intObservationIsEmpty = MsgBox("Please complete Observation for Tag before Confirming or Cancel!", vbCritical, "Observation is empty!!!")
Me.txt_Observation.SetFocus
Else
Me.Dirty = False (HERE IS WHERE THE "NotInList" EVENT IS FIRED AGAIN)
DoCmd.Close
End If
End Sub
Private Sub cmd_Cancel_Click()
On Error GoTo Err_cmd_Cancel_Click
Me.Undo
Me.Dirty = False
Forms!frm_Tag_Observation_Selection.Form![cbx_TagDescription].Undo
DoCmd.Close
Exit_cmd_Cancel_Click:
Exit Sub
Err_cmd_Cancel_Click:
MsgBox Err.Description
Resume Exit_cmd_Cancel_Click
End Sub
Any help is always apreciated!
Thx,
4N6MSTR
______________________________________________
If you don't know where you are going
It does not matter how fast you are
You will never get there