linking forms

  • Thread starter Thread starter Highlands Mining P/L
  • Start date Start date
H

Highlands Mining P/L

hi,

i've got another question regarding linking forms and displaying
information.

I want to select something from a listbox (on the first form) and i want the
2nd form to open with information from the database regarding the selection
from the listbox on the first form.

e.g. if i have a listbox of different projects say, project A, project B and
project C. I want to select Project A and i want to go to the next form
which has information about project A....e.g project name, start date etc.
But if i select project B, i want to load a form that has info about that
project. I dont want to create 3 different forms, one for each project. i
just want one form that can change the displayed information.

thanks!
 
Create your second form so that it shown ALL the projects - don't worry
about filtering. Then, add a command button to the first form and put this
code in its Click event procedure:

Private Sub cmdShowDetails_Click()
DoCmd.OpenForm "frmProjectDetails", , , _
"[ProjectID]=" & lstSelectProject
End Sub

where:
cmdShowDetails is the name of the command button
frmProjectDetails is the name of the second form
lstSelectProject is the name of your listbox
ProjectID is the name of the primary key field in your projects table

If ProjectID is a text field then you will need to enclose the value in
quotes:
"[ProjectID]='" & lstSelectProject & "'"
 
Graham Mandeno said:
Create your second form so that it shown ALL the projects - don't worry
about filtering. Then, add a command button to the first form and put this
code in its Click event procedure:

Private Sub cmdShowDetails_Click()
DoCmd.OpenForm "frmProjectDetails", , , _
"[ProjectID]=" & lstSelectProject
End Sub

where:
cmdShowDetails is the name of the command button
frmProjectDetails is the name of the second form
lstSelectProject is the name of your listbox
ProjectID is the name of the primary key field in your projects table

If ProjectID is a text field then you will need to enclose the value in
quotes:
"[ProjectID]='" & lstSelectProject & "'"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

hi,

i dont really understand what you mean by this: Create your second form so
that it shown ALL the projects .
I created a 2nd form with all the attributes in my projects table and i
tried your code, but when the 2nd form is loaded all of the text boxes are
empty ???

Sorry, i'm new to access!
 
Back
Top