Question : Passing parameter by open args

I want to pass an ID from one form to an unbound form.
I am filling in the openargs parameter in the docmd.openform
But when the form opens the openargs is null.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Private Sub cmd_SendID_Click()
On Error GoTo Err_cmd_SendID_Click
 
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stLinkCriteria = Me![SendID]
    stLinkCriteria = "123"  ' test purposes
    stDocName = "frmCustomer"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_cmd_SendID_Click:
    Exit Sub
 
Err_cmd_SendID_Click:
    MsgBox Err.Description
    Resume Exit_cmd_SendID_Click
    
End Sub

Answer : Passing parameter by open args

change this

    DoCmd.OpenForm stDocName, , , stLinkCriteria
   
to

    DoCmd.OpenForm stDocName, openargs:= stLinkCriteria
   
in the load event of frmCustomer, use this codes

private sub form_load()
if len(me.openargs)>0 then
    me.textboxName=me.openargs
end if

end sub

Random Solutions  
 
programming4us programming4us