Hi,
I am having a problem and and hoping you can help. This is long, but I really need your help. I have a two forms once called "Customer" and the other called "Part" (this is not a subform). On the customer form I have a integer field (auto sequenced) called Custid.
Code: On the customer form I have a button called "Add Part" and have the following code on the On-click event of my button.
Private Sub Open_Part_Click()
On Error GoTo Err_Add_Part_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Part"
stLinkCriteria = "[Custid]=" & Me![Custid]
MsgBox (stLinkCriteria)
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Add_Part_Click:
Exit Sub
Err_Add_Part_Click:
MsgBox Err.Description
Resume Exit_Add_Part_Click
End Sub
In the Part form, I have a "Custid" field (it is a foreign key). Here is my form On-Load event code:
Private Sub Form_Load()
numcustid = Forms!Customer.OpenArgs
' If numcustid > 0 Then
' DoCmd.GoToControl "Custid"
' DoCmd.FindRecord numcustid, , True, , True, , True
' Else
' Part.Custid = numcustid
' End If
End Sub
Now this works when I am enter the form and I have a part record. It goes to the correct record. However if no part already existed then the custid is empty and I can not fill it. I want to be able to add parts as well as edit and delete, so I need to somehow get the custid being past into the Part form and whenever I am adding be able to copy it to the cust id into the part form.
If you got this far, I really, really appricate it. I really could use some ideas as to how to proceed. Any and all help is appriciate it.