HOW TO MOVE FOCUS TO ANOTHER FIELD IN A FORM

D

DVANANTHAN

dear sir

I am a middle aged retired man and I am trying to learn MSaccess2007 . I
have created a small database and i am trying to create a data entry form. In
the form i want to move from one field to another depending on the value
entered in a particular field. For example i have a field called "Doc Type"-
If i enter the value" Cashsheet" , then it should move to a field called
"Week Number" other wise it should skip this"week Number" field and go to
the next "Details of DOC" field. Please note that the Week "Number filed"
should normally be locked and should be opened for data entry only if
"DocType" is Cashsheet. Is it possible?

I do not know visual basic and would like to use the wizard , expression
builder etc.. available in ms access.
 
D

Daryl S

Dvananthan -

Yes, this is possible. You want to set enabled property for the "Week
Number" control to "No". This will mean the cursor will not go into that
field, and the user cannot update it.

Then you need to put some code in the AfterUpdate event of the control for
the "Doc Type". The code will look like this:
If Me.[Doc Type] = "Cashsheet" Then
Me.[Week Number].Enabled = True
Else
Me.[Week Number].Enabled = False
End If

The "Me." construct tells Access we are talking about the current form, so
the code above must reference the control names, not the field names.

Hope that helps!
 

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