A list of values

G

Guest

Dears,

Good morning.
Could you please help me to create a list of values?

I have two fields in a form and sub-form (Form1.GOVERNANCE and Form2.GATE).

And I have a table (DELIVERABLES) that has this two fields and another field
called DELIVERABLE.

For each GOVERNANCE + GATE, I have a list of DELIVERABLES.

I need to populate a list box (Form2.DELIVERABLE) in the form and I tried to
do it, using the DLookup function bellow:

Dim XGovernance As String
Dim XGate As String

XGovernance = Form_1.GOVERNANCE
XGate = F2.GATE

Form2.DELIVERABLE = DLookup("[DELIVERABLE]", "[DELIVERABLES]", _
"GOVERNANCE=[XGovernance] AND GATE=[XGate]")

However, the DLookup function is used for just one value.
How can I do it?

Could you please, help me?

Thanks and regards.

PH.
 
D

Douglas J Steele

Try replacing what you've got with:

Me.MyListBox.RowSourceType = "Table/Query"
Me.MyListBox.RowSource = "SELECT [DELIVERABLE] " & _
"FROM [DELIVERABLES] " & _
"WHERE GOVERNANCE= '" & [XGovernance] & _
"' AND GATE='" & [XGate] & "'"

This assumes that both GOVERNANCE and GATE are text fields. If they aren't,
remove the single quotes from the expression above.
 
G

Guest

Dear Douglas,

Good afternoon.
Thanks for help me.
I tried to execute it, however, instead of get the values, it openned me a
message box asking for Governance and Gate values.

I would like that the Governance and Gate assume the values I already filled
in the form.

Could you please, help on how to fix it?

Thanks and regards.

PH.

Douglas J Steele said:
Try replacing what you've got with:

Me.MyListBox.RowSourceType = "Table/Query"
Me.MyListBox.RowSource = "SELECT [DELIVERABLE] " & _
"FROM [DELIVERABLES] " & _
"WHERE GOVERNANCE= '" & [XGovernance] & _
"' AND GATE='" & [XGate] & "'"

This assumes that both GOVERNANCE and GATE are text fields. If they aren't,
remove the single quotes from the expression above.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PH said:
Dears,

Good morning.
Could you please help me to create a list of values?

I have two fields in a form and sub-form (Form1.GOVERNANCE and Form2.GATE).

And I have a table (DELIVERABLES) that has this two fields and another field
called DELIVERABLE.

For each GOVERNANCE + GATE, I have a list of DELIVERABLES.

I need to populate a list box (Form2.DELIVERABLE) in the form and I tried to
do it, using the DLookup function bellow:

Dim XGovernance As String
Dim XGate As String

XGovernance = Form_1.GOVERNANCE
XGate = F2.GATE

Form2.DELIVERABLE = DLookup("[DELIVERABLE]", "[DELIVERABLES]", _
"GOVERNANCE=[XGovernance] AND GATE=[XGate]")

However, the DLookup function is used for just one value.
How can I do it?

Could you please, help me?

Thanks and regards.

PH.
 
G

Guest

Douglas,

Good afternoon.
It works !!!!!!
I had put a wrong field name. I fixed it and it works.

THANKS A LOT for your help.
Best regards.

PH.

PH said:
Dear Douglas,

Good afternoon.
Thanks for help me.
I tried to execute it, however, instead of get the values, it openned me a
message box asking for Governance and Gate values.

I would like that the Governance and Gate assume the values I already filled
in the form.

Could you please, help on how to fix it?

Thanks and regards.

PH.

Douglas J Steele said:
Try replacing what you've got with:

Me.MyListBox.RowSourceType = "Table/Query"
Me.MyListBox.RowSource = "SELECT [DELIVERABLE] " & _
"FROM [DELIVERABLES] " & _
"WHERE GOVERNANCE= '" & [XGovernance] & _
"' AND GATE='" & [XGate] & "'"

This assumes that both GOVERNANCE and GATE are text fields. If they aren't,
remove the single quotes from the expression above.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PH said:
Dears,

Good morning.
Could you please help me to create a list of values?

I have two fields in a form and sub-form (Form1.GOVERNANCE and Form2.GATE).

And I have a table (DELIVERABLES) that has this two fields and another field
called DELIVERABLE.

For each GOVERNANCE + GATE, I have a list of DELIVERABLES.

I need to populate a list box (Form2.DELIVERABLE) in the form and I tried to
do it, using the DLookup function bellow:

Dim XGovernance As String
Dim XGate As String

XGovernance = Form_1.GOVERNANCE
XGate = F2.GATE

Form2.DELIVERABLE = DLookup("[DELIVERABLE]", "[DELIVERABLES]", _
"GOVERNANCE=[XGovernance] AND GATE=[XGate]")

However, the DLookup function is used for just one value.
How can I do it?

Could you please, help me?

Thanks and regards.

PH.
 

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