VBA question

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

Hi there,
I am going through a recordset on open of my form and when I hit a certain
field, I choose if a certain control shows up on the form or not.
So when the control is a combo box, Is there a way to assign the row source
to the combo box through code?

Here is my Rowsource for the combo box I would like to use:
SELECT DISTINCT VisitCriteriaOption.CriteriaOptionValueText,
VisitCriteriaOption.SequenceNo, Visit.ClinicalTrialId
FROM (VisitCriteria INNER JOIN Visit ON VisitCriteria.ClinicalTrialId = Visit.
ClinicalTrialId) INNER JOIN VisitCriteriaOption ON (VisitCriteria.SequenceNo
= VisitCriteriaOption.SequenceNo) AND (VisitCriteria.ClinicalTrialId =
VisitCriteriaOption.ClinicalTrialId)
WHERE (((VisitCriteriaOption.SequenceNo)=2) AND ((Visit.ClinicalTrialId)
=GetActiveStudy()));

One last thing, I have an Integer that I declared called Sequence.
How do I substitute my WHERE
WHERE (((VisitCriteriaOption.SequenceNo)=2)

to say WHERE (((VisitCriteriaOption.SequenceNo)= Sequence)

Thanks for your help in advance, I hope I provided enough info.
 
S

S.Clark

me.cboName.rowsource = "Queryname or SQL"

dim intSequence as integer
intSequence = ... 'However you determine it
strSQL = "Select * from tablename where Sequence = " & intSequence
 
G

gmazza via AccessMonster.com

Thanks for the reply!
But can you use both together?
Can't use & intSequence in a query, correct?


S.Clark said:
me.cboName.rowsource = "Queryname or SQL"

dim intSequence as integer
intSequence = ... 'However you determine it
strSQL = "Select * from tablename where Sequence = " & intSequence
Hi there,
I am going through a recordset on open of my form and when I hit a certain
[quoted text clipped - 19 lines]
Thanks for your help in advance, I hope I provided enough info.
 
S

S.Clark

You asked how to do it in code, which I assumed meant VBA. Now you're asking
if you can use in query, and the answer is no.

I don't know what you mean by 'both together'.

gmazza via AccessMonster.com said:
Thanks for the reply!
But can you use both together?
Can't use & intSequence in a query, correct?


S.Clark said:
me.cboName.rowsource = "Queryname or SQL"

dim intSequence as integer
intSequence = ... 'However you determine it
strSQL = "Select * from tablename where Sequence = " & intSequence
Hi there,
I am going through a recordset on open of my form and when I hit a certain
[quoted text clipped - 19 lines]
Thanks for your help in advance, I hope I provided enough info.
 

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