Conditional Column Property Change

A

anasser

In my Access 2002 database, I have a table that the users call from a
button. My question is: How can I make the data in a column on that
table defaulting to only one value based on a specific criterion in my
VBA code, or have it as any normal column based on other criteria in my
VBA code without putting the table in a form.
Example:
Table A structure:
Column1 Column2 Column3 Column4

VBA Button Click:

if x = 1 then
'Code to make entries to Column3 limited to the value "00000000"
end if

if x = 2 then
'Code to make entries to Column3 unlimited and normal like all the
rest of the columns
end if

Any ideas on this matter is appreciated,

Thanks
 
V

Van T. Dinh

If I read your question correctly, you want to do this in the DatasheetView
of the Table, NOT in a Form?

DatasheetView of the Table doesn't not have Events which you can hook your
VBA code into to execute the code. Hence it is not possible. In fact, I
don't even know how you can have a CommandButton on the DatasheetView of the
Table???

You can use a Form in DatasheetView instead.
 
A

anasser

the button is on a different form that closes the form and opens the
table. I was thinking maybe its possible to edit the table properties
in the code of the button before The table is loaded...is that possible?
 
V

Van T. Dinh

While it is possible to modify the Table, it is much easier to open the
DatasheetView of a Form (which will look like the DatasheetView of the
Table) and you can set default value, disable / enable the Control that is
bound to the required Field you want to restrict / unrestrict and also use
the BeforeUpdate Event to validate the data entered!
 

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