Automaticly fill form field in access 2003

H

Harry

Hi Everyone,
Being rather new in Access I face a challenge.
I have a form named Contacts and within this form 2 address groups.
First the visit adres and secondly the postal adres.
so; form fields are contacts.address contacts.postalcode contacts.city
contacts.country
secondly the fields are contacts.addresspost contacts.postalcodepost
contacts.citypost contacts.country.
Now I would like to have filled in the "post" fields automatically with the
content of the visitadress, when the postal adresses are not filled in by
hand.
Within the table all fields are set to text and all fields are within the
same table.
The form fields are not a combobox.
Has anyone some idea how to accomplish?
 
A

Anthos

Harry welcome to MS Access, hope you enjoy developing in it as much as
I do.

Your best bet if you want this is to use the lost focus event on the
field.

Code as per the following.

'//begin code
Me.addresspost.value = me.visitaddress.text

End Sub

'//End Code

This should do exactly what you are after.
 
H

Harry

Thanx Anthos,
It did in some way help me out, however I did not succeed to run the
statement.
Can you explain how to activate the control.
I have tried to connect it to the form field (addresspost) before update and
secondly to the form field address after update. But unfortunately is doesnt
work.

Would you please be so kind to help me with this, by fi writing down a
statement(procedure) and some guidance to implement it in my project.
I was planning to implement a checkbox with the meaning. Enabled >>
visitaddres=postadress and unchecked postadres is different to visitadres and
the data has to be entered manually.

Greetings,
Harry
 
A

Anthos

Assuming your checkbox on your form is called Check2 then the
following code should work

'//Begin Code
Private Sub Check2_AfterUpdate()
If Me.Check2.Value = True Then
Me.AddressPost.Value = Me.Address.Value
Me.PostalCodePost.Value = Me.postalcode.Value
Me.City.Value = Me.CityPost.Value
Me.Countrypost.Value = Me.Country.Value
Else
Me.AddressPost.Value = ""
Me.PostalCodePost.Value = ""
Me.CityPost.Value = ""
Me.Countrypost.Value = ""
End If
End Sub

'//End Code

Hope this helps.

My initial post about using the .text property is incorrect, as the
record would in theory be already updated.
 
H

Harry

Thanx Anthos,

This was the script I was looking for!!. Thanks a lot. You really helped me
out!
I did have to make a slight alteration to your script, but that was only due
to some restrictions within my table (fieldrestrictions)

I'm enjoying developing MS Access, more and more

Greetings, Harry
 

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