VBA refence to a Field Name in a Table

eschaef2

Registered User.
Local time
Today, 07:40
Joined
Jul 25, 2002
Messages
12
Good Morning All.

I've looked through how to reference a control on a form with VBA, and am looking for a similar type of statement for a table.

My issue:
13 columns named N_Month01 through N_Month13, and a For Next loop that steps through 1 to 13.

Buried in the code, I determine if there is a count (N) for the month that I am looking at (1 through 13), and want that data field to be the value of N.

I am stuck on how to code the statement, and make it executable. Here is a copy of what I have now:


For I = 1 to 13
strFieldName = "N_Month" & Right$("0" & I, 2)

...
... code for determining if there were any events this month, and counting the total as [N] in rstTemp
...
If rstTemp.RecordCount > 0 Then
rstTemp.MoveFirst
rstOutput(strFieldName) = rstTemp![N]

Else
rstOutput(strFieldName) = 0

End If
rstTemp.Close

Next I
rstOutput.Update


Note: If there were events in the given month (1 to 13), rstTemp.RecordCount will be one and the value of N is the number of events, otherwise, rstTemp is an empty set.

My Issue: rstOutput shows up with all zeros at the end

Any advice or direction would be greatly appreciated.

Thanks, and Best Regards,
Eric
 
address the field directly by this syntax

controls("n_month"& intvar)
 

Users who are viewing this thread

Back
Top Bottom