Recordset question/problem

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

gmazza via AccessMonster.com

Hey there,
I am trying to manipulate certain records in a table during certain form
actions.
I am opening a recordset and everything, but I only want to manipulate
records with a certain Trial Id.
Here is some sample data:
TrialId CriteriaValue TitleValue
CriteriaText
1 Activity1 Activity
yes
1 Activity2
1 Activity3

2 HeadacheDay1
yes
2 HeadacheDay2
2 HeadacheDay3

I want to only go through the records that are on TrialId 2.
I tried opening a recordset for this table and if its TrialId 2 then I open
another recordset for this table and go through hoping it is still on the
TrialId 2 records but it doesn't work as opening another recordset goes back
to the first record of the table again.

Is there a way I can go through the records until I hit TrialId 2, then
maipulate those records?

Any help is appreciated!
 
C

Clifford Bass

Hi,

Just use an SQL statement instead of opening the table directly. So if
your table is tblTrials your SQL might be:

select * from tblTrials where TrialID = 2

This will give you only the rows where TrialID is 2.

Clifford Bass
 
G

gmazza via AccessMonster.com

Thanks for the reply.
How can I do that in VBA? This code is in the On Open event of my form and I
need to show/hide certain labels depending on this. I don't see how a select
can work here??

Clifford said:
Hi,

Just use an SQL statement instead of opening the table directly. So if
your table is tblTrials your SQL might be:

select * from tblTrials where TrialID = 2

This will give you only the rows where TrialID is 2.

Clifford Bass
Hey there,
I am trying to manipulate certain records in a table during certain form
[quoted text clipped - 24 lines]
Any help is appreciated!
 
C

Clifford Bass

Hi,

I presume you have something like this:

Set rst = CurrentDb.OpenRecordset("tblTrials")

Change it to something like this (assuming that the desired trial ID is
in a variable named "lngTrialID":

Set rst = CurrentDb.OpenRecordset("select * from tblTrials where TrialID = "
& lngTrailID)

If that does not help, how about posting your relavent code?

Clifford Bass
 

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