Question If else statements?

realtorDC

New member
Local time
Yesterday, 16:30
Joined
Oct 18, 2010
Messages
5
Sorry I am a total noob to access and not sure what forum section this shoudl go in, I do have some C++ and php experience though. I just started playing around with Access and so far so good.

I have several tables, I am a real estate agent, so I have a table for friends, a table for past clients, a table for potential clients, etc.

I am creating a mail merge for potential clients that might want to sell their home, I figured out how to do what I need except one caveat, sometimes the owners do not live at the property I want to sell. So to solve this I figure I will have "Street" "City" "State" "Zip" of the property, then I have a field called Absentee that is a YES/NO to be checked if they do not live there, then I have another set for the address to mail to if they are absent "Mail Street", "Mail City", etc.

Basically, I have not done any coding in Access but I would like my table to work like this..

if ( Absentee == false)
{

Street = Mail Street;
City = Mail City;
Zip = Mail Zip;

}


Basically, copy what I wrote into Street for the mailing unless I check Absentee.. Can I do this?

That way on my letter when I reference the property I can Reference "Street", but to make sure it goes to the right address on the envelop I will reference "Mail Street"...

How do I do this?
 
In stead of three tables I'd probably store all your contacts in the one table and differentiate them using an option group to indicate their status. This will make things easier when it comes to selecting contacts as they are all in the one table.

I'm presuming that Absentee is a check box, so in it's on click event put something along the lines of;
Code:
If Me.Absentee = False Then
     Me.Street = Me.[Mail Street]
     Me.City = Me.[Mail City]
     Me.Zip = Me.[Mail Zip]
Else
     Me.Street = ""
     Me.City = ""
     Me.Zip =  ""
End If
 
......additionally avoid using spaces and other special characters in control and object name, limit yourself to alpha numeric characters and the under score (_), this make writing code a whole lot easier.
 
Thanks John! A couple questions.. is "Me" the name of my table in this case "FSBO"?

Also, how do I go about implementing code into my tables?
 
Tables are only for the storage of your data and your users should only interact with that data via a form. In this way you can control what they see, what they enter and how they interact with that data, it also gives you more control over the validation of the data being entered.

Me. is a reference to a control on the current form, if you wish to reference a control or object on another form the reference will be different.
 

Users who are viewing this thread

Back
Top Bottom