Passing Data from one form to another, revisited

D

David Wetmore

I am trying to pass a key from one form to another form, not a sub form.

In the originating form I have the following code:

Private Sub cmdEdit_DeleteRecord_Click()
DoCmd.OpenForm ("frmEditDeleteData")
Forms!frmEditDeleteData.txtIncomingHeader = CStr(intHeaderKey)
End Sub

In the destination form the Form_Activate event closes the originating form with

If CurrentProject.AllForms("frmViewRecords").IsLoaded Then
DoCmd.Close acForm, "frmViewRecords"
End If

In this destination form txtIncomingHeader is an unbound text box.
When I execute the form the value of the passed header key is
displayed in txtIncomingHeader. BUT, it seems to be read-only. I can't
access or change the data in the textbox.

How do I get to the contents of txtIncomingHeader?

Thanks
 
S

Steve Sanford

Hi David,

This is how I would do it using the "OpenArgs" clause of the DoCmd.OpenForm
command.

In the originating form I would have the following code:

Private Sub cmdEdit_DeleteRecord_Click()
DoCmd.OpenForm ("frmEditDeleteData"), , , , , , CStr(intHeaderKey)
DoCmd.Close acForm, Me.Name
End Sub


In the "destination" form (frmEditDeleteData), I would have:

Private Sub Form_Load()
If Len(Nz(Me.OpenArgs, "")) > 0 Then
Me.txtIncomingHeader = Me.OpenArgs
End If
End Sub


In design view, open the properties dialog box for the control
"txtIncomingHeader" and check the Enabled and locked properties (DATA tab)
are set to:

Enabled:YES
Locked: NO



HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top