I've got a form with feilds: Address, Suburb, State, Pcode (for the
Location Addres) and then: PAddress, PSuburb, PState, PPcode (for the
Postal Address).
When the postal address is the same as the location address, it becomes
cumbersome to retype/copy the address into the postal address fields so
I created a tick box (like a 'same as above' thingy) where on
'afterupdate' i've put the following code as an Event Procedure:
Private Sub Same_As_Above_AfterUpdate()
[PAddress] = [Address]
[PSuburb] = [Suburb]
[PState] = [State]
[PPcode] = [Pcode]
End Sub
The obvious problem here is that it updates all 4 postal address fields
wether you tick or untick the box.
What code do i need to insert (or create from scratch) to tell it to
only update the 4 postal address fields _when_the_box_is_ticked_?
Also, it would be nice to have some code that tells it to clear the 4
fields if the box is 'unticked' later.
Any help would be appreciated!!
Thanks
Farqs 11 4133
farqs <mf*****@yahoo.com.au> wrote: I've got a form with feilds: Address, Suburb, State, Pcode (for the Location Addres) and then: PAddress, PSuburb, PState, PPcode (for the Postal Address).
When the postal address is the same as the location address, it becomes cumbersome to retype/copy the address into the postal address fields so I created a tick box (like a 'same as above' thingy) where on 'afterupdate' i've put the following code as an Event Procedure:
Private Sub Same_As_Above_AfterUpdate() [PAddress] = [Address] [PSuburb] = [Suburb] [PState] = [State] [PPcode] = [Pcode] End Sub
The obvious problem here is that it updates all 4 postal address fields wether you tick or untick the box.
What code do i need to insert (or create from scratch) to tell it to only update the 4 postal address fields _when_the_box_is_ticked_? Also, it would be nice to have some code that tells it to clear the 4 fields if the box is 'unticked' later.
Any help would be appreciated!!
Thanks Farqs
Ummm, simple.....
Private Sub Same_As_Above_AfterUpdate()
If Me![Same_As_Above] Then
Me![PAddress] = Me![Address]
Me![PSuburb] = Me![Suburb]
Me![PState] = Me![State]
Me![PPcode] = Me![Pcode]
Else
Me![PAddress] = Null
Me![PSuburb] = Null
Me![PState] = Null
Me![PPcode] = Null
End If
End Sub
--
regards,
Bradley
A Christian Response http://www.pastornet.net.au/response
.... and i just thought of something else...
It would be nice if a warning popped up if you were to tick the box
when the postal address is already typed in, BUT is different to the
location address. (useful for if someones postal address changes to
their location address (for some reason), at a later date)
Cheers
Farqs
You're a legend Bradley!! Works like a charm.
Cheers
Farqs
Sorry that should have read:
....useful for if you tick the box by mistake)
Sorry, wasn't thinking straight
Farqs
farqs <mf*****@yahoo.com.au> wrote: ... and i just thought of something else...
It would be nice if a warning popped up if you were to tick the box when the postal address is already typed in, BUT is different to the location address. (useful for if someones postal address changes to their location address (for some reason), at a later date)
Cheers Farqs
Again simple... just do a comparison like.....
If (Me![PAddr] = Me![Addr]) And (Me![PSuburb] = Me![Suburb]) And
[............etc]
Then
Msgbox "Warning"
End If
--
regards,
Bradley
A Christian Response http://www.pastornet.net.au/response
Sorry Bradley. I think i confused things. I'll try again.
Is it possible for a warning message to pop up ONLY when you tick the
box WHEN the postal address has already been typed in AND is different
to the location address? (as a safeguard for if you tick the box by
accident) It should not pop up if the postal address fields are blank
or when 'unticking' the box.
When the warning pops up, it should give you the option to cancel or
continue BEFORE updating/changing the fields.
Hope that makes sense.
Cheers
farqs <mf*****@yahoo.com.au> wrote: Sorry Bradley. I think i confused things. I'll try again.
Is it possible for a warning message to pop up ONLY when you tick the box WHEN the postal address has already been typed in AND is different to the location address? (as a safeguard for if you tick the box by accident) It should not pop up if the postal address fields are blank or when 'unticking' the box.
When the warning pops up, it should give you the option to cancel or continue BEFORE updating/changing the fields.
Hope that makes sense.
Cheers
That's exactly what I understood... do you want me to do ALL the work
for you?
Just modify the last code I gave you and insert a check to see if the
values are the same and put a warning message in.
--
regards,
Bradley
A Christian Response http://www.pastornet.net.au/response
Again...sorry Bradley. I didn't make myself clear.
I'm not a newb to Access, but am a newb to the coding side of it. This
is why i'm posting. The only coding I know is when searching for other
topics on google and dabbling with the coding I've found in the search.
Having never come across this latest requirement of mine in access and
never having learnt the programming/coding side of it, your second
response was a bit beyond my capabilities.
I did have a play with it though (as that's how I learn things and
because you suggested it) and found that the warning box only allows
you to press OK. It doesn't give you the option to change your mind
(in the case of having pressed it in error).
In your coding above, it compares when [paddr] = [addr] etc. Shouldn't
it be searching for when [paddr] does not = [addr] or am i reading your
coding wrong?
Also, the warning pops up every time you activate the tick box, even
when the postal address feilds are blank. It should only pop up when
something different is in the postal address
Regards
Farqs
PS I really appreciate your help.
farqs <mf*****@yahoo.com.au> wrote: Again...sorry Bradley. I didn't make myself clear.
I'm not a newb to Access, but am a newb to the coding side of it. This is why i'm posting. The only coding I know is when searching for other topics on google and dabbling with the coding I've found in the search. Having never come across this latest requirement of mine in access and never having learnt the programming/coding side of it, your second response was a bit beyond my capabilities.
I did have a play with it though (as that's how I learn things and because you suggested it) and found that the warning box only allows you to press OK. It doesn't give you the option to change your mind (in the case of having pressed it in error).
Look up the Access help. There are several options for what appears in
your message box (eg. Yes/No, OK/Cancel....). Then read the return
value of the Msgbox to determine what the user pressed and then take the
appropraite action.
eg.
Dim r as Long
r = MsgBox("prompt", vbExclamation + vbOKCancel +
vbDefaultButton2,"title")
If r = vbOK Then
'copy field values
End If
In your coding above, it compares when [paddr] = [addr] etc. Shouldn't it be searching for when [paddr] does not = [addr] or am i reading your coding wrong?
It was just an example. Alter the logic to suit.
Also, the warning pops up every time you activate the tick box, even when the postal address feilds are blank. It should only pop up when something different is in the postal address
Then add more checks before you open the message box.
eg. (check the logic... it's just an example)
If ((Not IsNull(Me![Addr]) And (Me![Addr] <> Me![PAddr])) And
((Not IsNull(Me![Addr2]) And (Me![Addr2] <> Me![PAddr2])) And .... etc
etc
Then
Msgbox "Warning"
End If
--
regards,
Bradley
A Christian Response http://www.pastornet.net.au/response
Thanks for your patience.
I'll have a play with it and let you know how i go.
Regards
Farqs
Thanks for your help Bradley. Much appreciated.
I got it to work. You had a parenthisis missing in the checking code,
but i assume you did this on purpose ;-). Anyway I came up with the
following (Don't laugh...it works):
Private Sub VA_SAA_AfterUpdate()
If ((Not IsNull(Me![VA_ADD])) And (Me![VA_ADD] <> Me![VA_PA_ADDRESS]))
And ((Not IsNull(Me![VA_SUBURB])) And (Me![VA_SUBURB] <>
Me![VA_PA_SUBURB])) And ((Not IsNull(Me![VA_STATE])) And (Me![VA_STATE]
<> Me![VA_PA_STATE])) And ((Not IsNull(Me![VA_POSTCODE])) And
(Me![VA_POSTCODE] <> Me![VA_PA_POSTCODE])) Then
Dim r As Long
r = MsgBox("You are about to delete this agencies Postal Address and
replace it with the Location Address. Do you want to continue?",
vbExclamation + vbYesNo + vbDefaultButton2, "Warning")
If r = vbYes Then
Me![VA_PA_ADDRESS] = Me![VA_ADD]
Me![VA_PA_SUBURB] = Me![VA_SUBURB]
Me![VA_PA_STATE] = Me![VA_STATE]
Me![VA_PA_POSTCODE] = Me![VA_POSTCODE]
Else
If r = vbNo Then
Me![VA_SAA] = Null
End
End If
End If
End If
If Me![VA_SAA] Then
Me![VA_PA_ADDRESS] = Me![VA_ADD]
Me![VA_PA_SUBURB] = Me![VA_SUBURB]
Me![VA_PA_STATE] = Me![VA_STATE]
Me![VA_PA_POSTCODE] = Me![VA_POSTCODE]
Else
Me![VA_PA_ADDRESS] = Null
Me![VA_PA_SUBURB] = Null
Me![VA_PA_STATE] = Null
Me![VA_PA_POSTCODE] = Null
End If
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg |
last post by:
I keep getting an error when I have a tick mark in a text value that I am
searching for in my XPath Query.
Example:
<Authors>
<Author LastName="O'Donnel">
<Author LastName="Smith">...
|
by: bq |
last post by:
In the code
int a;
int b = -1;
does ANSI C guarantee that "b" is located in memory right after "a"
so that "a" refers to "b"?
Thanks.
bq
|
by: Martin Eyles |
last post by:
Hi,
I want to make a scale on a graph, by telling asp to insert empty divs
of class tick, and the setting the style in css. I am trying to get a 3D
effect by using colored top and bottom borders...
|
by: Rich |
last post by:
Here is what I am trying for randomizing 2 numbers in the same subroutine so
that they are not equal to each other:
Dim j As Integer, k As Integer
j = New System.Random().Next(0, 10)
k = New...
|
by: Phoenix_ver10 |
last post by:
I have a mailing list with multiple names going to the same addresses.
I need one address with all the names for that address on it. I checked
out the example on microsoft's site, but A: It doesn't...
| |
by: appelsinagurk |
last post by:
Hi
I'm fairly new to .Net programming so I'll try to explain my problem as easy as I can, and in advanced sorry for my poor english.
I've got some spare hours where I work, so I've decided to...
|
by: paul.bentley |
last post by:
I am trying to get a "Date entered" box to automatically fill when a
tick box = true, without success so its over to the experts for some
much needed help
Thanks in advance
|
by: sweeneye |
last post by:
Hi,
I'm basing a query on the variables used in a form. The database contains lots of problems, say with a computer and a tick box for the apropriate component like monitor, keyboard, mouse etc....
|
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= |
last post by:
I am trying to get the DNS name of an arbitrary IP address on the network.
If I use GetHostEntry as the documentation suggests I only get the name of
the machine I am running the code on. All...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |