Referencing to a Subform within a Form (1 Viewer)

mbertuol

Registered User.
Local time
Today, 05:22
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
 

KenHigg

Registered User
Local time
Today, 04:22
Joined
Jun 9, 2004
Messages
13,327
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
 

mbertuol

Registered User.
Local time
Today, 05:22
Joined
Apr 3, 2004
Messages
26
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

  • sample.zip
    66.3 KB · Views: 110

daveUK

Registered User.
Local time
Today, 09:22
Joined
Jan 2, 2002
Messages
234
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.
 

mbertuol

Registered User.
Local time
Today, 05:22
Joined
Apr 3, 2004
Messages
26
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?
 

daveUK

Registered User.
Local time
Today, 09:22
Joined
Jan 2, 2002
Messages
234
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

  • bd1_2000.zip
    69.1 KB · Views: 113

mbertuol

Registered User.
Local time
Today, 05:22
Joined
Apr 3, 2004
Messages
26
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

  • bd1_2000_updated.zip
    61.8 KB · Views: 114

daveUK

Registered User.
Local time
Today, 09:22
Joined
Jan 2, 2002
Messages
234
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"
 

mbertuol

Registered User.
Local time
Today, 05:22
Joined
Apr 3, 2004
Messages
26
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.
 

Peter D

Registered User.
Local time
Today, 09:22
Joined
Sep 7, 2000
Messages
188
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

Top Bottom