473,748 Members | 5,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flip-flop textbox values using a checkbox

9 New Member
Here's my dilema:

My database is built around people and their contact info. On my "data entry form" there is a place for their main address, and on the subform which is attached to the main form, is a place for the person's home address. I have a checkbox on the main form which I want to use to swap/flip-flop the home address with the main address.

The concept I have figured out for the most part, but the code is the actual problem. I know I need some kind of "middleman" to temporarily store the data while it's switched but I've got no idea on how to go about doing this. Any and all help would be greatly appreciated.
Mar 8 '07 #1
7 2805
ADezii
8,834 Recognized Expert Expert
Here's my dilema:

My database is built around people and their contact info. On my "data entry form" there is a place for their main address, and on the subform which is attached to the main form, is a place for the person's home address. I have a checkbox on the main form which I want to use to swap/flip-flop the home address with the main address.

The concept I have figured out for the most part, but the code is the actual problem. I know I need some kind of "middleman" to temporarily store the data while it's switched but I've got no idea on how to go about doing this. Any and all help would be greatly appreciated.
Here is the Code Template to accomplish what you are requesting. Substitute Control and Field Names wherever appropriate:
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkTest_Click()
  2. Dim intResponse As Integer
  3.  
  4. intResponse = MsgBox("Swap Main and Home Addressess?", vbYesNo + vbQuestion + vbDefaultButton1, "Address Swap")
  5.  
  6. If intResponse = vbNo Then Exit Sub
  7.  
  8. Dim strMainAddress As String, strHomeAddress As String
  9.  
  10. strMainAddress = Me![txtMainAddress]
  11. strHomeAddress = Me![subfChild].Form![txtHomeAddress]
  12.  
  13. Me![txtMainAddress] = strHomeAddress
  14. Me![subfChild].Form![txtHomeAddress] = strMainAddress
  15. End Sub
Mar 8 '07 #2
kumana1
9 New Member
Thank you for that!
Mar 8 '07 #3
ADezii
8,834 Recognized Expert Expert
Thank you for that!
No problemo.
Mar 8 '07 #4
kumana1
9 New Member
Works like a charm, as long as there's an address present in the residence address text box. If the residence address is left blank, I get an "Invalid Null" error. To combat this, this is what I've tried, but still get the error.

Expand|Select|Wrap|Line Numbers
  1. strMainAddress = Me![FCIL Address]
  2. strHomeAddress = Me![subform_Master_subData].Form![Residence Address]
  3.  
  4. If strHomeAddress = Null Then
  5. intResponse = MsgBox("No address to swap, do it anyways?", vbYesNo + vbQuestion + vbDefaultButton1, "No Address to Swap")
  6.  
  7.     If intResponse = vbNo Then Exit Sub
  8.  
  9.     Else:
  10.     Me![FCIL Address] = strHomeAddress
  11.     Me![subform_Master_subData].Form![Residence Address] = strMainAddress
  12.     End If
  13.  
  14. Me![FCIL Address] = strHomeAddress
  15. Me![subform_Master_subData].Form![Residence Address] = strMainAddress
  16.  
  17. End Sub
Mar 8 '07 #5
NeoPa
32,571 Recognized Expert Moderator MVP
Try this modified version of ADezii's code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkTest_Click()
  2.   Dim intResponse As Integer
  3.   Dim varMainAddress As Variant, varHomeAddress As Variant
  4.  
  5.   intResponse = MsgBox("Swap Main and Home Addressess?", vbYesNo + vbQuestion + vbDefaultButton1, "Address Swap")
  6.  
  7.   If intResponse = vbNo Then Exit Sub
  8.  
  9.   varMainAddress = Me![txtMainAddress]
  10.   varHomeAddress = Me![subfChild].Form![txtHomeAddress]
  11.  
  12.   Me![txtMainAddress] = varHomeAddress
  13.   Me![subfChild].Form![txtHomeAddress] = varMainAddress
  14. End Sub
Mar 9 '07 #6
kumana1
9 New Member
Wow, that is a lot easier then what I was trying to do. Thanks so much for everyone's help.
Mar 9 '07 #7
NeoPa
32,571 Recognized Expert Moderator MVP
Not a problem.
ADezii produced most of it, I just tweaked it to handle Nulls.
Mar 9 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3049
by: RicercatoreSbadato | last post by:
I have to flip vertically a Bitmap. Is it possible with GDI+ and C#?
0
1299
by: Mr. A | last post by:
I'm looking for a code to flip a window, like in the Tiger - Apple OS. I though of the following algorithm but I can get it implemented right: 1. Capture the window who is about to be flipped. 2. Hide it and display the image. This is the part which I don't know how to implement: 3. Start changing the image size so it looks like its being flipped. 4. Display a new window which is the "back side" of the original window.
2
1363
by: JC | last post by:
Can someone send me a link where I can make the flip-down menu on this page ? http://www.renzifoodservice.com/service_solutions.asp Or, does anyone do that, and would be willing to create something like that for me ? Let me know your fee.
4
7453
by: theNetDragon | last post by:
hi all I see on a site which show a book and with ur mouse you are flipping the papers, this code is very complex can any one help me u can find the on this link http://www.islamway.com/hajj26/ u will fine a link at lower left corner, click and flip the papers of book with ur mouse .....
0
847
by: David S. Zuza | last post by:
I know this is a strange question. I want to be able to reverse the display and/or flip it whenever I need in the program and was wondering if there was a way to do it. I am trying to make it so that the software can be viewed in a mirror or not if the user wants. thanx in advance, David S. Zuza
0
1548
by: coolindienc | last post by:
Honestly, I am totally lost about this program. I don't even know where to start. At first I thought I can ask a user to flip a coin. But then again one will get bored flipping coin fot 100 times. How do I get a computer to flip coin and get result? Any ideas??? Any help will be greatly appreciated greatly!!!!!!!! Andy
6
15745
by: Francesco Moi | last post by:
Hi. I'd like to flip horizontally an image with JavaScript. Is it possible? Thank you very much.
3
6099
by: realNewbie | last post by:
I am creating a python program that will flip a coin 100 times and then tells you the number of heads and tails. This is for a class I am taking, I am not looking for the answer. I have already started writing the program, but something is missing because it will not run...can someone let me know if they can see my error? import random heads=0 tails=0 count=1 while count <101: randomFlip = random.randrange(0,1) if randomFlip == 0: ...
6
4409
by: shailendrab | last post by:
Hi, I have been trying to flip an image vertically before saving in disk in AVI format. I really dont know why i need to flip it first before saving, any idea? To do this currently i am performing a simple algorithm... public Bitmap RotateFlip(Bitmap source, RotateFlipType change) { Bitmap dest = new Bitmap(source.Size.Width, source.Size.Height); int MaxWidthIndex = source.Size.Width - 1;
0
1084
by: Anthony Follari | last post by:
Hello, I've been working on a simple Java platformer and I need some help with image manipulation. I'm looking for a way to flip (about the y-axis) the various player sprites I have depending on the direction of the player (left/right). I've tried a bunch of Google searches and they all seem to suggest the "AffineTransform" class but I'm really not sure how you use it. I don't just want to paint a flipped image to the screen but rather be...
0
8991
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8243
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.