linking forms

  • Thread starter Highlands Mining P/L
  • 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!
 
G

Graham Mandeno

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 & "'"
 
M

Miranda

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!
 

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