Link Split Form to New Form

steve21nj

Registered User.
Local time
Today, 11:17
Joined
Sep 11, 2012
Messages
260
Good Morning,

I have a split form ‘frmRequisitionList’ that loads data from a query. On this form I am attempting to link the RequisitionID to populate another form ‘AReviewPurchaseOrder’ to review the data. Form ‘AreviewPurchaseOrder’ also has a subform. I have the following code but it returns a run-time error ‘2465’ can’t find the field ‘RequisitionID’ referred to in your expression. Am I leaving something out?

Code:
[FONT=Calibri][SIZE=3]Option Compare Database[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Private Sub ID_Click()[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Dim stDocName As String[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]   Dim stLinkCriteria As String[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]stDocName = "AReviewPurchaseOrder"[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]stLinkCriteria = "[RequisitionID]=" & "'" & Me![RequisitionID] & "'"[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]   DoCmd.OpenForm stDocName, , , stLinkCriteria[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]End Sub[/SIZE][/FONT]
 
I am not entierly sure.. but is ID a Text? If not.. try your criteria as..
Code:
stLinkCriteria = "[RequisitionID]=" & Me![RequisitionID]
 
pr2,
Thank you for the quick response. ID is the name of the text box that holds the control source 'RequisitionID'.
I tried your suggested but returned the same error.
 
Okay.. Now, Does the Form AReviewPurchaseOrder have a ControlName [RequisitionID]?? Because Opening a Second Form with Criteria looks for a ControlName [RequisitionID].. Look HERE for more info...
 
I re-read the page a few times, and I want to make sure that I am doing this correctly. Right now the code no longer displays an error, it opens the second form, but does not link the data.

New Form = AReviewPurchaseOrder
New Form Field Name = txtReq
Control Name used by both forms = RequistionID


Code:
Private Sub txtRequisition_Click()
DoCmd.OpenForm "AReviewPurchaseOrder", , , "txtReq = '" & Me.RequisitionID & "'"
End Sub

Additional, can I later make the txt fieldname not visible without it affecting this transfer? I rather the ID not be visible on the new form if possible.

Thank you
 
I had a chance to work with the code, I am able to pass the main form information but not the subform. Also, I think I have alot of "fluff" within the code that I can remove, but I am not 100% certain. Anyone have any ideas on how to link my subform 'tblLineItemsDetails subform'???
Thanks in advance

Code:
Private Sub txtRequisition_Click()
On Error GoTo txtRequisition_Click_Err
 
    DoCmd.OpenForm "AReviewPurchaseOrder", acNormal, "", "[RequistionID]= " & Nz(RequistionID, 0), , acDialog
 
    If (IsNull(RequistionID)) Then
        TempVars.Add "CurrentID", Nz(DMax("[RequistionID]", Form.RecordSource), 0)
    End If
    DoCmd.Requery ""
    DoCmd.SearchForRecord , "", acFirst, "[RequistionID]= " & TempVars!CurrentID
    TempVars.Remove "CurrentID"
txtRequisition_Click_Exit:
    Exit Sub
txtRequisition_Click_Err:
    MsgBox Error$
    Resume txtRequisition_Click_Exit
End Sub
 

Users who are viewing this thread

Back
Top Bottom