R
rm
Well I am still having fun with this problem. Thanks to " Marsh MVP
[MS Access] " for your help.
I am trying to be a little more specific with names as I describe the
problem again.
I have a main form "frmDOMain", an imbeded form "frmDOstatus" (the
control is named "sfrmDOstatus"). When the user double clicks on a
record in "frmDOstatus" another form - "frmMngStatus" opens. The
purpose of "frmMngStatus" is to allow the user to add a child record
to the parent record presented in "frmDOMain". When the user selects
"Save" from "frmMngStatus" then a record is written to a table (via
ADO) that is used to supply data for "frmDOstatus" (the sub form on
"frmDOMain").
The goal is that after the user selects "save" from "frmMngStatus"
that the added record shows up in the subform ("frmDOstatus") on the
main form ("frmDOMain").
If all that didn't make sense the flow is - Open main form with
embeded form/child record. Double click on embeded form - pop-up form
is displayed. New child record/Information is added in the pop-up
form. Pop-up form is closed. What is expected next is new child record
is displayed in the embeded form.
The problem is that the child record is displayed *for the first
several iterations of the process only*. Then at some point the child
record no longer shows up in the subform "frmDOstatus" after the user
selects "save" from ""frmMngStatus".
When the record stops displaying as expected then I can execute a go
next, move prev routine (sometimes as many as 3 x for it to work) then
the child cecord is displayed. In addition to the fact that the same
exact, unchanged code produces inconsistent results the frustration is
that the child record is written to the table every single time.
Here is the code from "frmMngStatus":
Private Sub cmdUpdate_Click()
Dim lngStatusID As Long
Dim strNotes As String
Dim dteDate As Date
Dim objCon As ADODB.Connection
Dim objCmd As ADODB.Command
Dim objPrm As ADODB.Parameter
Set objCon = New ADODB.Connection
Set objCmd = New ADODB.Command
Set objPrm = New ADODB.Parameter
If IsNull(cboStatus.Value) Then
MsgBox "Please Select a Status Message", vbOKOnly, "Error"
Me.cboStatus.SetFocus
Else
lngStatusID = Me.cboStatus.Value
dteDate = CDate(Format(Now(), "dd mmm yyyy"))
If Not IsNull(txtNotes.Value) Then
strNotes = Me.txtNotes.Value
Else
strNotes = ""
End If
objCon.Open (CurrentProject.Connection)
'Setup Command Object for DB Call
With objCmd
.CommandText = "sp_insert_do_status"
.CommandType = adCmdStoredProc
.ActiveConnection = objCon
Set objPrm = .CreateParameter("do_id", adInteger,
adParamInput, , g_lngDOID)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("s_id", adInteger,
adParamInput, , lngStatusID)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("dte", adDate,
adParamInput, , dteDate)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("StatusNotes", adVarChar,
adParamInput, 255, strNotes)
.Parameters.Append objPrm
.Execute '< Works every single time!
End With
objCon.Close
Set objCon = Nothing
Set objCmd = Nothing
Set objPrm = Nothing
Forms!frmDOMain!sfrmDOStatus.Form.Requery 'doesn't work
DoEvents
Forms!frmDOMain!sfrmDOStatus.Form.Refresh 'no good
DoEvents
Forms!frmDOMain!sfrmDOStatus.Form.Repaint 'doesn't do it
DoEvents
'tried...
'Dim frm as FORM_frmDOStatus
'Set frm = New FORM_frmDOStatus
'frm.Requery
'I think this is way off
DoCmd.Close acForm, "frmMngStatus"
End If
This project is turning out to be deadly. I am in the Army in Iraq.
When I walk outside people lob mortars at my head. When I walk inside
the COL is going to chew my head off because he wants his reports - he
may just put me out on the street. Microsoft is literally going to put
me in harms way! (OK it is only a joke [kind of - sort of] - I am in
the Army and am in Iraq though).
Can somebody help a soldier out!?
[MS Access] " for your help.
I am trying to be a little more specific with names as I describe the
problem again.
I have a main form "frmDOMain", an imbeded form "frmDOstatus" (the
control is named "sfrmDOstatus"). When the user double clicks on a
record in "frmDOstatus" another form - "frmMngStatus" opens. The
purpose of "frmMngStatus" is to allow the user to add a child record
to the parent record presented in "frmDOMain". When the user selects
"Save" from "frmMngStatus" then a record is written to a table (via
ADO) that is used to supply data for "frmDOstatus" (the sub form on
"frmDOMain").
The goal is that after the user selects "save" from "frmMngStatus"
that the added record shows up in the subform ("frmDOstatus") on the
main form ("frmDOMain").
If all that didn't make sense the flow is - Open main form with
embeded form/child record. Double click on embeded form - pop-up form
is displayed. New child record/Information is added in the pop-up
form. Pop-up form is closed. What is expected next is new child record
is displayed in the embeded form.
The problem is that the child record is displayed *for the first
several iterations of the process only*. Then at some point the child
record no longer shows up in the subform "frmDOstatus" after the user
selects "save" from ""frmMngStatus".
When the record stops displaying as expected then I can execute a go
next, move prev routine (sometimes as many as 3 x for it to work) then
the child cecord is displayed. In addition to the fact that the same
exact, unchanged code produces inconsistent results the frustration is
that the child record is written to the table every single time.
Here is the code from "frmMngStatus":
Private Sub cmdUpdate_Click()
Dim lngStatusID As Long
Dim strNotes As String
Dim dteDate As Date
Dim objCon As ADODB.Connection
Dim objCmd As ADODB.Command
Dim objPrm As ADODB.Parameter
Set objCon = New ADODB.Connection
Set objCmd = New ADODB.Command
Set objPrm = New ADODB.Parameter
If IsNull(cboStatus.Value) Then
MsgBox "Please Select a Status Message", vbOKOnly, "Error"
Me.cboStatus.SetFocus
Else
lngStatusID = Me.cboStatus.Value
dteDate = CDate(Format(Now(), "dd mmm yyyy"))
If Not IsNull(txtNotes.Value) Then
strNotes = Me.txtNotes.Value
Else
strNotes = ""
End If
objCon.Open (CurrentProject.Connection)
'Setup Command Object for DB Call
With objCmd
.CommandText = "sp_insert_do_status"
.CommandType = adCmdStoredProc
.ActiveConnection = objCon
Set objPrm = .CreateParameter("do_id", adInteger,
adParamInput, , g_lngDOID)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("s_id", adInteger,
adParamInput, , lngStatusID)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("dte", adDate,
adParamInput, , dteDate)
.Parameters.Append objPrm
Set objPrm = .CreateParameter("StatusNotes", adVarChar,
adParamInput, 255, strNotes)
.Parameters.Append objPrm
.Execute '< Works every single time!
End With
objCon.Close
Set objCon = Nothing
Set objCmd = Nothing
Set objPrm = Nothing
Forms!frmDOMain!sfrmDOStatus.Form.Requery 'doesn't work
DoEvents
Forms!frmDOMain!sfrmDOStatus.Form.Refresh 'no good
DoEvents
Forms!frmDOMain!sfrmDOStatus.Form.Repaint 'doesn't do it
DoEvents
'tried...
'Dim frm as FORM_frmDOStatus
'Set frm = New FORM_frmDOStatus
'frm.Requery
'I think this is way off
DoCmd.Close acForm, "frmMngStatus"
End If
This project is turning out to be deadly. I am in the Army in Iraq.
When I walk outside people lob mortars at my head. When I walk inside
the COL is going to chew my head off because he wants his reports - he
may just put me out on the street. Microsoft is literally going to put
me in harms way! (OK it is only a joke [kind of - sort of] - I am in
the Army and am in Iraq though).
Can somebody help a soldier out!?