changing defaultvalue

A

Art Vandaley

Hi,

I have two questions:

1)
I try to change defaultvalue property of a Table's field with using code.
That code is run inside Autoexec macro and it has a inputbox asking a string
like "Myvalue". I want the function changes one of the table1's field's
default value as "Myvalue". For this reason I wrote a function doing this.
I've written something like:

Public Function AD()
Dim Message, Title, Default, MyValue
Message = "Please enter your name"
Title = "User Information"
Default = "Name"

MyValue = InputBox(Message, Title, Default)

(*) table1!field1.defaultvalue= Myvalue

End Function

The row I marked with (*) is not accepted (debug window opens). How can I
correct it?

2) I want "Myvalue" to be asked only one time (first time that user opens
the database). What kind of check to be done by above code?

I will appreciate your help. Best Regards.
 
R

Rick Brandt

Art Vandaley said:
Hi,

I have two questions:

1)
I try to change defaultvalue property of a Table's field with using code. That
code is run inside Autoexec macro and it has a inputbox asking a string like
"Myvalue". I want the function changes one of the table1's field's default
value as "Myvalue". For this reason I wrote a function doing this. I've
written something like:

Public Function AD()
Dim Message, Title, Default, MyValue
Message = "Please enter your name"
Title = "User Information"
Default = "Name"

MyValue = InputBox(Message, Title, Default)

(*) table1!field1.defaultvalue= Myvalue

End Function

The row I marked with (*) is not accepted (debug window opens). How can I
correct it?

2) I want "Myvalue" to be asked only one time (first time that user opens the
database). What kind of check to be done by above code?

I will appreciate your help. Best Regards.

While it is possible to change the DefaultValue at the table level it is bit
more involved than one line of code. Far easier to modify the default value
property on the *form* being used for data entry. Your code could either open
the form and apply the default value or save it in a public variable so it can
be applied in the Open event of the form (if it will opened later).
 

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