I have created a main form and a related form that I call with the click of a command button. I am trying to pass the value in the linking field to the called form, and it just isn't working. The called form "knows" it's being filtered but doesn't have the value I passed it in the correct field. I have no idea what I am doing wrong and am hoping someone can help me.
tblCD_SupplyID - this is the field I am trying to populate on the called form
tblS_ID - is the field on the calling form that contains the value
I have used a msgbox and tracing to make sure the correct value is in tblS-ID, and it is.
Please help. Thanks -- Judy
tblCD_SupplyID - this is the field I am trying to populate on the called form
tblS_ID - is the field on the calling form that contains the value
I have used a msgbox and tracing to make sure the correct value is in tblS-ID, and it is.
Code:
Private Sub cmdCraftDetail_Click()
'---------------------------------------------------------------------
'Purpose: Open the subformfrmSub_CraftDetail when button is clicked
' and sync the supply id on the two forms. Issue error if
' there's no information on the main form
'Date: 05/18/17
'
'Note: This is NOT working! It opens the form but doesn't populate
' the linked field with the supply ID
'---------------------------------------------------------------------
On Error GoTo err_cmdCraftDetail_Click
Dim strDocName As String 'name of form to be ordered
Dim strLinkCriteria As String
Dim strTitle As String
Dim strMessage As String
Dim intButton As Integer
Dim intChoice As Integer
strDocName = "frmSub_CraftDetail"
strLinkCriteria = "[tblCD_SupplyID]=" & Me![tblS_ID]
' Example: DoCmd.OpenForm "frmMainEmployees", , , "DepartmentID=" & cboDept.Value
'MsgBox strLinkCriteria
'DoCmd.OpenForm strDocName, , , "tblCD_SupplyID=" & tblS_ID.Value
DoCmd.OpenForm strDocName, , , strLinkCriteria
Exit_cmdOrderType_Click:
Exit Sub
err_cmdCraftDetail_Click:
strTitle = "Supply Error"
If Err.Number = 3075 Then
strMessage = "you must enter the Supply Name before " & _
vbCrLf & "opening the Craft Detail form"
Else
strMessage = Err.Number & ": " & Error.Description
End If
intButton = vbOKOnly + vbExclamation + vbDefaultButton1
intChoice = MsgBox(strMessage, intButton, strTitle)
Resume Exit_cmdOrderType_Click
End Sub
Please help. Thanks -- Judy