Referencing to a Subform within a Form

mbertuol

Registered User.
Local time
Yesterday, 23:15
Joined
Apr 3, 2004
Messages
26
Hello,

I have the following command in a listbox:

Code:
Private Sub List15_AfterUpdate()
    DoCmd.Requery "List15"
    DoCmd.OpenForm "fmProjects", , , "[ID] = " & Me.List15, , acDialog
End Sub

I want to use a similar command when the form "fmProjects" is within a tab of another form, such as:
fmMainForm: has a tab control. Each tab has a subform. One of the subforms is "fmProjects".

How could I reference it?

Thanks in advance for any help.

Mauro
 
Just ref it like the tabs didn't exist.

forms!frmMain!subfrmMain.form!myControl1

Ref's a control named 'myControl1' on sub form 'subfrmMain' on form 'frmMain'.

kh
 
It does not seem to work in the way I need. I am attaching an example. First open 'subfrmTest' and click on any record of the list box. Then open the 'frmMain' and try to do same.

Thanks,
 

Attachments

mbertoul,

Delete the code and set the Control source of

ID to
Code:
=[Lista5].column(0)
Name to
Code:
=[Lista5].column(1)
Company to
Code:
=[Lista5].column(2)

This will display the selected values.
 
Dave,

Thanks for your reply. I have have not made myself clear in the message with the DB samples. What I want is:

1) use frmMain
2) when I select a record in the list, that record is displayed

subfrmTest is displaying correctly...

Any hint?
 
mbertoul,

I've attached the database (in 2000 format) with the changes I suggested. The selected record is displayed whether the user uses frmsubtest or frmmain. Let me know if this is what you wanted.

Dave
 

Attachments

Dave,

Thank you for your help but it it not solve the problem. You understood the form/subform has to display the content of the list. In fact the list shows the result of a given search. The objetive is that when the user clicks over a given record in the list, such record is diplayed entirely in the form. I have updated the DB for clarity sakeness. Please take a look.

Thank you,

Mauro
 

Attachments

If I understand what you want - you want the user to select a record from the listbox on FrmMain and then that record will open up on SubfrmTest.

To do this, just remove the following line from your code

Code:
DoCmd.Requery "List15"
 
No! If the user selects a record on the frmMain I want that same record to be displayed in there. As it is now, subform pops up. It should not.
 
Try putting the following code in your listbox AfterUpdate event procedure (replace the two lines that are there):

Dim rsClone As dao.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "[ID] = " & Me.Lista5

If rsClone.NoMatch Then
If Me.DataEntry Then
MsgBox "Record could not be found because this form is a data entry form (DataEntry property is set to 'Yes')."
Else
MsgBox "Record not found"
End If
Else
Me.Bookmark = rsClone.Bookmark
End If
rsClone.Close
Set rsClone = Nothing


Hope this helps,
 

Users who are viewing this thread

Back
Top Bottom