Basically I have made a database that does all of my company's human resources needs. Now I have no training and everything has been learned from trial and error and/or looking up on the internet, but try as I might, I cannot find the answer to this question.

Basically on one of the forms to enter the personal information of an employee I enter their physical and mailing address. I have a check box that I would like to automatically fill the mailing address with the physical address if the checkbox is filled.

I have tryed the following in the coding area, but it will not work:

If MAILCHECK.text = 1 then MAILADDRESS.text = PHYSADDRESS.text
(I also had if 0 = " " ) ( (The MAILCHECK is the checkbox name, and the other two are the names of the text boxes from the table that need to be filled)

Truthfully this is purely cosmetic and doesn't hinder the database, but it is really annoying and not as perfect as I want it.

I hope I explained the problem well, and someone will have the knowledge to help me. Otherwise I have to keep pounding my head on the screen and having migraines! Thank you.

Try this:
On the AfterUpdate event of the check box, use this code:

Private Sub MAILCHECK _AfterUpdate()
  If Me.MAILCHECK Then
    Me.MAILADDRESS= Me.PHYSADDRESS
  End If
End Sub

This code will run after a user either checks or unchecks the check box. If the checkbox is checked, then MAILCHECK is true, so everything in the If block will run, which is to set the MAILADDRESS to the PHYADDRESS.

That did it, thanks!

Sorry for the late reply!

Is there a way to set it up that when the checkbox is unchecked the boxes fill with previous data? Like if someone accidentally clicked it and overwrote good date.

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.