Subforms- Pages- Linking

G

Guest

Hi,
I will try and explain this as clearly as possible... I have a main
form with five tabs, one of the tabs has a subform, on the subform I
have a column called "Status". This subform contains details from the
Project Table, with the unique Project_ID. I also have a separate
table Project Status which relates to the Project Table by the
Project_ID. What I would like to have happen is that when you click
on "Status" another form pops up with data from the Project Status
table using the Project_ID from the subform that you just clicked on.
The problem I have is that everytime I click on the "status" link,
Access says that it can't find the subform that it's looking for. I
don't know the correct naming for the code. This is the code as I
have it now:
Private Sub Status_Click()
On Error GoTo Err_Status_Click

DoCmd.RunCommand acCmdWindowHide
DoCmd.OpenForm "Project Status"


Forms![Main Form].[Project_Estimates_Subform].Form!Project_ID =
Forms![Project Status lfb]!Project_ID


Exit_Status_Click:
Exit Sub


Err_Status_Click:
MsgBox Err.Description
Resume Exit_Status_Click
End Sub


Any help would be GREATLY appreciated. I've been trying to figure
this out and haven't a clue.
Thanks,
krista
 
G

Guest

krista:

As, if I understand you correctly, the code is being executed in the
subform's module you don't need to worry about referencing it fully, you can
simply use Me, or even omit it altogether. Secondly you need to filter the
Project Status form; at present you seem to be trying to assign a value to
the subform's Project_ID, which doesn't make a lot of sense to me. The
relevant code to open the Project Status form filtered would be like this:

Dim strCriteria As String

strCriteria = "Project_ID = " & Me.Project_ID

DoCmd.OpenForm "Project Status", _
WhereCondition:=strCriteria, _
WindowMode:=acDialog

As well as filtering the form to the current Project_ID the above code
opens it in dialogue mode, which forces the user to close (or at least hide)
it before returning to the original form.

Ken Sheridan
Stafford, England
 
G

Guest

Hi Ken,
Thank you so much! It turns out that it was a combination of an incorrect
code as well as a bad criteria on a list box in the Project Status form. I
really appreciate you getting back to me so quickly.

krista

Ken Sheridan said:
krista:

As, if I understand you correctly, the code is being executed in the
subform's module you don't need to worry about referencing it fully, you can
simply use Me, or even omit it altogether. Secondly you need to filter the
Project Status form; at present you seem to be trying to assign a value to
the subform's Project_ID, which doesn't make a lot of sense to me. The
relevant code to open the Project Status form filtered would be like this:

Dim strCriteria As String

strCriteria = "Project_ID = " & Me.Project_ID

DoCmd.OpenForm "Project Status", _
WhereCondition:=strCriteria, _
WindowMode:=acDialog

As well as filtering the form to the current Project_ID the above code
opens it in dialogue mode, which forces the user to close (or at least hide)
it before returning to the original form.

Ken Sheridan
Stafford, England

Krista said:
Hi,
I will try and explain this as clearly as possible... I have a main
form with five tabs, one of the tabs has a subform, on the subform I
have a column called "Status". This subform contains details from the
Project Table, with the unique Project_ID. I also have a separate
table Project Status which relates to the Project Table by the
Project_ID. What I would like to have happen is that when you click
on "Status" another form pops up with data from the Project Status
table using the Project_ID from the subform that you just clicked on.
The problem I have is that everytime I click on the "status" link,
Access says that it can't find the subform that it's looking for. I
don't know the correct naming for the code. This is the code as I
have it now:
Private Sub Status_Click()
On Error GoTo Err_Status_Click

DoCmd.RunCommand acCmdWindowHide
DoCmd.OpenForm "Project Status"


Forms![Main Form].[Project_Estimates_Subform].Form!Project_ID =
Forms![Project Status lfb]!Project_ID


Exit_Status_Click:
Exit Sub


Err_Status_Click:
MsgBox Err.Description
Resume Exit_Status_Click
End Sub


Any help would be GREATLY appreciated. I've been trying to figure
this out and haven't a clue.
Thanks,
krista
 

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