P
plh
I have a form "frmParts" within which is a subform "frmToolAssems".
Within frmToolAssems are two combo boxes which can be filled either by picking
from the drop-down list in the standard way *OR* by double-clicking, which opens
one of two forms: "frmTools" or "frmHolders", depending on which combo box the
user is using.
If the user selects an existing record from frmTools or frmHolders, then selects
the command button which passes the value along (using OpenArgs, see below), the
new entry does not show up on the subform within the parent form. I can make the
new entry "show up" with a requery. This is not ideal, but OTOH not a disaster.
BUT if the user creates a new record in frmTools or frmHolders, and passes the
value (yes, the record is committed, as indicated by the little pencil turning
into a triangle) then a requery does not do the trick. I have to close the
parent form (frmParts) and re-open it in order for the new entry to show up.
This IS a real problem. I might add that I don't programmatically close the
parent form when starting this process. In the end I might have to do that,
figuring out a way to make it go to the correct record upon re-opening. However,
I WOULD like to understand what is going on.
Thank you all in advance!
-plh
PS:
Here is the relevant code.
frmTools passes the value to the receiving form using this code:
Private Sub cmdCloseAndPassValue_Click()
On Error GoTo Err_cmdCloseAndPassValue_Click
lngTabelRef = Me.txtCurrTool.Value
DoCmd.OpenForm "frmToolAssems", acNormal, , , , , OpenArgs & ";" & lngTabelRef
DoCmd.Close acForm, "frmTools"
....
(error handling)
....
End Sub
frmHolders passes the value to the recieving form using this code:
Private Sub cmdPassHolder_Click()
lngHolder = Me.txtCurHldr.Value
DoCmd.OpenForm "frmToolAssems", acNormal, , , , , OpenArgs & ";" & lngHolder *
-1
'multiply by negative one to distinguish it from a change of tool
DoCmd.Close acForm, "frmHolders"
End Sub
frmToolAssems recieves this information with this code:
Private Sub Form_Open(Cancel As Integer)
'MsgBox (OpenArgs)
Dim rst As Recordset
Dim lngRec As Long
Dim lngTool As Long
Dim lngHldr As Long
Dim varRec
Dim varTool
Dim bolOK As Boolean
bolOK = False
Set rst = Me.RecordsetClone
If Not IsNull(OpenArgs) Then
varRec = Left(OpenArgs, InStr(OpenArgs, ";") - 1)
varTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
If IsNull(varRec) Or varRec = "" Then
lngRec = 0 'enabels triggering of addition of new tool
lngTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
Else
lngRec = Left(OpenArgs, InStr(OpenArgs, ";") - 1)
lngTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
End If
If lngRec > 0 And lngTool > 0 Then
'case if we want to change the *TOOL* on the current tool assembly recor
'in frmParts
With rst
.MoveFirst
While Not .EOF
If !IDToolAssem = lngRec Then
.Edit
!ToolDescription = lngTool
.Update
bolOK = True
End If
.MoveNext
Wend
End With
ElseIf lngRec > 0 And lngTool < 0 Then
'case if we want to change the *HOLDER* on the current tool assembly recor
'in frmParts -- note that we are using the variable lngTool to carry the holder
value
With rst
.MoveFirst
While Not .EOF
If !IDToolAssem = lngRec Then
.Edit
!ToolHolder = lngTool * -1
.Update
bolOK = True
End If
.MoveNext
Wend
End With
ElseIf lngRec = 0 And lngTool > 0 Then
'case if we are creating a new entry in the tool assembly list
'in frmParts
'if we are adding new we will have to have a tool holder
With rst
.AddNew
!ToolDescription = lngTool
!ToolHolder = GetHolder()
!IDPart = lngCurPart
.Update
bolOK = True
End With
End If 'If lngRec > 0 And lngTool > 0 Then -- ElseIf lngRec = 0 And lngTool > 0
Then
Me.Requery
DoCmd.Close acForm, "frmToolAssems"
End If 'If Not IsNull(OpenArgs) Then
End Sub
Within frmToolAssems are two combo boxes which can be filled either by picking
from the drop-down list in the standard way *OR* by double-clicking, which opens
one of two forms: "frmTools" or "frmHolders", depending on which combo box the
user is using.
If the user selects an existing record from frmTools or frmHolders, then selects
the command button which passes the value along (using OpenArgs, see below), the
new entry does not show up on the subform within the parent form. I can make the
new entry "show up" with a requery. This is not ideal, but OTOH not a disaster.
BUT if the user creates a new record in frmTools or frmHolders, and passes the
value (yes, the record is committed, as indicated by the little pencil turning
into a triangle) then a requery does not do the trick. I have to close the
parent form (frmParts) and re-open it in order for the new entry to show up.
This IS a real problem. I might add that I don't programmatically close the
parent form when starting this process. In the end I might have to do that,
figuring out a way to make it go to the correct record upon re-opening. However,
I WOULD like to understand what is going on.
Thank you all in advance!
-plh
PS:
Here is the relevant code.
frmTools passes the value to the receiving form using this code:
Private Sub cmdCloseAndPassValue_Click()
On Error GoTo Err_cmdCloseAndPassValue_Click
lngTabelRef = Me.txtCurrTool.Value
DoCmd.OpenForm "frmToolAssems", acNormal, , , , , OpenArgs & ";" & lngTabelRef
DoCmd.Close acForm, "frmTools"
....
(error handling)
....
End Sub
frmHolders passes the value to the recieving form using this code:
Private Sub cmdPassHolder_Click()
lngHolder = Me.txtCurHldr.Value
DoCmd.OpenForm "frmToolAssems", acNormal, , , , , OpenArgs & ";" & lngHolder *
-1
'multiply by negative one to distinguish it from a change of tool
DoCmd.Close acForm, "frmHolders"
End Sub
frmToolAssems recieves this information with this code:
Private Sub Form_Open(Cancel As Integer)
'MsgBox (OpenArgs)
Dim rst As Recordset
Dim lngRec As Long
Dim lngTool As Long
Dim lngHldr As Long
Dim varRec
Dim varTool
Dim bolOK As Boolean
bolOK = False
Set rst = Me.RecordsetClone
If Not IsNull(OpenArgs) Then
varRec = Left(OpenArgs, InStr(OpenArgs, ";") - 1)
varTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
If IsNull(varRec) Or varRec = "" Then
lngRec = 0 'enabels triggering of addition of new tool
lngTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
Else
lngRec = Left(OpenArgs, InStr(OpenArgs, ";") - 1)
lngTool = Right(OpenArgs, Len(OpenArgs) - InStr(OpenArgs, ";"))
End If
If lngRec > 0 And lngTool > 0 Then
'case if we want to change the *TOOL* on the current tool assembly recor
'in frmParts
With rst
.MoveFirst
While Not .EOF
If !IDToolAssem = lngRec Then
.Edit
!ToolDescription = lngTool
.Update
bolOK = True
End If
.MoveNext
Wend
End With
ElseIf lngRec > 0 And lngTool < 0 Then
'case if we want to change the *HOLDER* on the current tool assembly recor
'in frmParts -- note that we are using the variable lngTool to carry the holder
value
With rst
.MoveFirst
While Not .EOF
If !IDToolAssem = lngRec Then
.Edit
!ToolHolder = lngTool * -1
.Update
bolOK = True
End If
.MoveNext
Wend
End With
ElseIf lngRec = 0 And lngTool > 0 Then
'case if we are creating a new entry in the tool assembly list
'in frmParts
'if we are adding new we will have to have a tool holder
With rst
.AddNew
!ToolDescription = lngTool
!ToolHolder = GetHolder()
!IDPart = lngCurPart
.Update
bolOK = True
End With
End If 'If lngRec > 0 And lngTool > 0 Then -- ElseIf lngRec = 0 And lngTool > 0
Then
Me.Requery
DoCmd.Close acForm, "frmToolAssems"
End If 'If Not IsNull(OpenArgs) Then
End Sub