John,
I figured it out. This works in the open event:
Dim txtPart As String
If IsNull(Me.OpenArgs) Then
Exit Sub
Else
txtPart = Me.OpenArgs
If Len(txtPart) > 0 Then
Me.cboPart = Me.OpenArgs
Me.cboPart_AfterUpdate
End If
End If
Thanks for your help today. I learned some new things. :-)
Doyce
---In MS_Access_Professionals@yahoogroups.com, <winberry.doyce@...> wrote :
John,
You are right on target! That is just what it needed. Now that works. Perhaps you could help me with another bug. I want to open this form from another form where I look up a trailer and double click the trailer's BOM part number. So I put this code in the double click event of the trailer look up form:
'open form frmBOMLU and display BOM components
Dim txtPart As String
txtPart = Me.BOM
Debug.Print txtPart
DoCmd.OpenForm "frmBOMLU", acNormal, , , acFormReadOnly, , txtPart
This seems to work. it is trying to open the form and debug.print shows me the correct Part. However, here is the code I put in the open event of the secondary form:
Dim txtPart As String
Debug.Print Forms!frmVINInquiry.OpenArgs
txtPart = Forms!frmVINInquiry.OpenArgs
If Len(txtPart) > 0 Then
DoCmd.GoToControl "cboPart"
DoCmd.FindRecord txtPart, , True, , True, , True
End If
It errors on the line txtPart = Forms!frmVINInquiry.OpenArgs with "Invalid Use of Null". The debug.print on the line above show Null. So It is not picking up the value from OpenArgs but I don't know why.
Doyce
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
John Viescas, author
On Oct 21, 2016, at 16:51, winberry.doyce@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Hello Pros,
I need help on this one. I have a form that I want to use to drill down into a bill of material to look up parts. The parent form has a combo box that looks up a part from the part master table. There is a subform that shows the components of the part in the combo box. I want to be able to doubleclick on one of the components part numbers and have it move to the combo box on the parent form and display the components of that subassembly. The parent form is working fine. Whatever I select from the combo box, the components display. I put code in the doubleclick event of the components in the subform to update the combo box in the parent form and requery. However, when the form is requeried, it always displays the first record in the part master instead of the part in the combo box. What have I missed? Here is the code in the doubleclick event of the component n the subform:
'reset form to show components of part that is double clicked.
Dim txtPart
txtPart = Me.COMPRT_02
Me.Parent!cboPart = txtPart
Forms!frmBOMLU.cboPart.SetFocus
Debug.Print Me.Parent!cboPart
Me.Parent.Requery
Doyce
Posted by: winberry.doyce@con-way.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
Tidak ada komentar:
Posting Komentar