473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Flip-flop textbox values using a checkbox

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 2776
ADezii
8,834 Expert 8TB
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
Thank you for that!
Mar 8 '07 #3
ADezii
8,834 Expert 8TB
Thank you for that!
No problemo.
Mar 8 '07 #4
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,556 Expert Mod 16PB
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
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,556 Expert Mod 16PB
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
by: RicercatoreSbadato | last post by:
I have to flip vertically a Bitmap. Is it possible with GDI+ and C#?
0
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
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...
4
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...
0
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...
0
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....
6
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
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...
6
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.