Variables Containing Field Names That Contain Results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I must Search all the Fields that start with TxtAC that are in a form.

Each TxtAC field contains a number.

A Variable contains the name of the Field for which I must extract a number
to find a record in a Table that contains formulas.

The Users Group has been a big help so far in reducing the number of lines
(Currently between 16,000 and 16,500) of code in my program.

I have never used Controls before and this is where I need some help.

A sub-routine gets the record(s) that contain the formulas. It is names
GetRangeRec and works great.

Here is my present Code:

Dim HldCntrl as Control
Dim HldField as String
Dim IndxA as Byte

IndxA = 0
Do Until IndxA = 20
IndxA = IndxA + 1
HldCntrl = "TxtAC" & Format(IndxA, "00") Here is the
line that fails
HldField = Me("TxtAC" & Format(IndxA, "00"))
' MsgBox HldCntrl & " - " & HldField
' GetRangeRec(HldField, HldCntrl)
Loop

The Mesage I Get is:

Object variable or With block variable not set

Does anyone know what I am doing wrong?

Continued Help is Greatly Appreciated!

Granny
 
GrandMaMa said:
I must Search all the Fields that start with TxtAC that are in a form.

Each TxtAC field contains a number.

A Variable contains the name of the Field for which I must extract a number
to find a record in a Table that contains formulas.

The Users Group has been a big help so far in reducing the number of lines
(Currently between 16,000 and 16,500) of code in my program.

I have never used Controls before and this is where I need some help.

A sub-routine gets the record(s) that contain the formulas. It is names
GetRangeRec and works great.

Here is my present Code:

Dim HldCntrl as Control
Dim HldField as String
Dim IndxA as Byte

IndxA = 0
Do Until IndxA = 20
IndxA = IndxA + 1
HldCntrl = "TxtAC" & Format(IndxA, "00") Here is the
line that fails
HldField = Me("TxtAC" & Format(IndxA, "00"))
' MsgBox HldCntrl & " - " & HldField
' GetRangeRec(HldField, HldCntrl)
Loop

The Mesage I Get is:

Object variable or With block variable not set


You keep getting the variable/expression types mixed up ;-)

I think your code will work if you just change this one
line:
Dim HldCntrl As String

You could have this same problem, along with the extra
quotes, in your other thread, but you never did post the
entire procedure.

For future reference, before posting code you should first
compile it using the Debug - Compile menu item. This will
check for syntax and several other simple to fix errors.
Once the code compiles without error, then use Copy/Paste to
put the code in the post. This avoids any typos that might
be introduced by retyping.
 
Marshall Barton said:
You keep getting the variable/expression types mixed up ;-)

I think your code will work if you just change this one
line:
Dim HldCntrl As String

You could have this same problem, along with the extra
quotes, in your other thread, but you never did post the
entire procedure.

For future reference, before posting code you should first
compile it using the Debug - Compile menu item. This will
check for syntax and several other simple to fix errors.
Once the code compiles without error, then use Copy/Paste to
put the code in the post. This avoids any typos that might
be introduced by retyping.
 
Marshall;
Changing it to a string worked. One of the members felt it
needed to be a control.
By the way I have an immense problem with Debug on Large programs.

Debug runs fine on this program. I indicated the line on the
Watch function and everything. For some reason it just ignored the error.

Thanks A Lot, you were a big help.

By the way this test is for 9th graders to determine how much they retained
on learning Word and how to apply Word on explaining mathematical formulas so
they can be understood by the legal community. Needless to say it is an
Honors course. However the University of Iowa is recommending it become part
of the ACT in the future.

Thanks Again

Granny
 
Back
Top