Utilizing Recordset field in vb Requery Command Verbiage

S

stickandrock

I have a Record set loop set up in Vb. During the loop I want to utilize a
field returned within a command that uses another field with part of the same
name....

Table : Facilities
Field: Facility (Values 100,200,300,400)

I have a form that has 10 textboxes that are labeled Tot100Cnt, Tot200Cnt,
Tot300Cnt, etc..

I want to requery the textboxes utilizing the Recordset loop. Problem is I
am not sure how I need to format the command utilizing the returned recordset
field as part of the requery line. I don't want to code each field
independantly if I can use a looping function...

Hope this all makes sense....

sample code:
strSQL = "SELECT [FacilityList].Facility FROM [FacilityList] ORDER BY
[FacilityList].Facility"
Set rst = CurrentDb.OpenRecordset(strSQL)

If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF

Forms!main!Tot100Cnt.Requery
' Replacing "100" with the rst![Facility]
field
rst.MoveNext
Loop
End If
 
P

PieterLinden via AccessMonster.com

Start at the beginning... what is your goal in doing this? You're trying to
pass a value from a field in your recordset to something? Okay. Why? It
looks like you could do all this with DCount or similar and no code at all.
I have a Record set loop set up in Vb. During the loop I want to utilize a
field returned within a command that uses another field with part of the same
name....

Table : Facilities
Field: Facility (Values 100,200,300,400)

I have a form that has 10 textboxes that are labeled Tot100Cnt, Tot200Cnt,
Tot300Cnt, etc..

I want to requery the textboxes utilizing the Recordset loop. Problem is I
am not sure how I need to format the command utilizing the returned recordset
field as part of the requery line. I don't want to code each field
independantly if I can use a looping function...

Hope this all makes sense....

sample code:
strSQL = "SELECT [FacilityList].Facility FROM [FacilityList] ORDER BY
[FacilityList].Facility"
Set rst = CurrentDb.OpenRecordset(strSQL)

If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF

Forms!main!Tot100Cnt.Requery
' Replacing "100" with the rst![Facility]
field
rst.MoveNext
Loop
End If
 
S

stickandrock

I have several things I want to do to this group of fields. The sample code
was just there for an example.

I just trying to determine what is the proper format for utilizing a field
from a recordset as part of the form field name. I have a group of toggle
switches (Same type of naming convention) that I want to loop through and
being able to do that through a loop would be much more effiecient than code
each one individually.

Thanks,

PieterLinden via AccessMonster.com said:
Start at the beginning... what is your goal in doing this? You're trying to
pass a value from a field in your recordset to something? Okay. Why? It
looks like you could do all this with DCount or similar and no code at all.
I have a Record set loop set up in Vb. During the loop I want to utilize a
field returned within a command that uses another field with part of the same
name....

Table : Facilities
Field: Facility (Values 100,200,300,400)

I have a form that has 10 textboxes that are labeled Tot100Cnt, Tot200Cnt,
Tot300Cnt, etc..

I want to requery the textboxes utilizing the Recordset loop. Problem is I
am not sure how I need to format the command utilizing the returned recordset
field as part of the requery line. I don't want to code each field
independantly if I can use a looping function...

Hope this all makes sense....

sample code:
strSQL = "SELECT [FacilityList].Facility FROM [FacilityList] ORDER BY
[FacilityList].Facility"
Set rst = CurrentDb.OpenRecordset(strSQL)

If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF

Forms!main!Tot100Cnt.Requery
' Replacing "100" with the rst![Facility]
field
rst.MoveNext
Loop
End If

--



.
 

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