Referencing Public Constants Access 2000

D

DJ Walker

I am using access 2000 to write a program that will create
export files for our AccPac Accounting System.

These file deal with our Inventory Control Records.
Different departments will have different defaults for
many of the fields on the form.

I setup a Module for the form and in that module I have
created a Public const def#fieldname# where #fieldname#
are the field (Control) names in the table and on the
form. I have this code at the form open.

Private Sub Form_Open(Cancel As Integer)
Dim I As Integer, ctrlWork As Control
Dim varField As Variant
For I = 0 To Me.Count - 1
Set ctrlWork = Me.Controls(I)
If ctrlWork.ControlType > 100 Then
* varField = Eval("[def" & ctrlWork.Name & "]")
ctrlWork.DefaultValue = varField
End If

Next I
Set ctrlWork = Nothing
End Sub

My problem is the * line I get an error:
Run-time error '2432'"

Microsoft Access can't find the name 'defITEMNO' you
entered in the expression.

Is there a way to use a string to reference the constants.
I thought Eval() would work but I have hand no luck.

I have looked on the web but not found a way to reference
the constant.

Any help would be appreciated.

DJ Walker

Network Programmer
(e-mail address removed)
314-781-0900 ext 790

St Louis Zoo
Visit www.stlzoo.org <http://www.stlzoo.org>
The Saint Louis Zoo is accredited by the American Zoo and
Aquarium Association (AZA). Look for the logo whenever you
visit a zoo or aquarium as your assurance that you are
supporting a facility dedicated to providing excellent
care for animals, a great experience for you, and a better
future for all living things. With its more than 200
accredited members, AZA is a leader in global wildlife
conservation, and your link to helping animals in their
native habitats.
 

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