473,320 Members | 1,612 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,320 software developers and data experts.

Use a check box to duplicate data

I have a table coalled tAddress, which includes fields street, Suburb, city, home Phone

I have another table called tNOK (next of Kin) and the same address fields,

using subforms to enter data I also have a check box calle chkSameAsPerson

how can I get the check box to enter tAddress into tNOK and display it immediately on the form

both tables have a FK which is PersonID related to intial table, tPersonDetails
Do I need to relate the two tables directly first?

any help is much appreciated

Barry
Apr 23 '08 #1
4 1432
Delerna
1,134 Expert 1GB
On the code page for the form and in the click event for the cechbox
something like this should work
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkSameAsPerson_click()
  2.     Dim db As DAO.Database
  3.     Dim strSQL As String
  4.  
  5.     Set db = CurrentDb 
  6.     strSQL = "UPDATE tNOK SET street='" & TheNameOfThestreetTextbox & "' WHERE TheRelatedField=" TheNameOfTheRelatedFieldTextbox
  7.     db.Execute strSQL
  8.     Set db = Nothing
  9. End Sub
  10.  
Bear in mind that the above will not a work. It is merely an example as you do not have enough info in your question.
So take the above, adjust it to suit your particular problem and use the help files to guide you.

Note that since the controls that contain the address you want to copy are on a subform you will need to take that into account when referencing TheNameOfThestreetTextbox and TheNameOfTheRelatedFieldTextbox etc.

Have a go youself, you will learn more that way. If you stike a barrier then come back and ask here.


PS. The above is only one way to achieve what you want, there are other ways.
Apr 24 '08 #2
Hi, I'm struggling here!!

I have a form called fSubDemogs with two subforms fPtAddress and fNOKAddress.

text box on fPtaddress is TxtPtStreet underlying field is 'Street' from table tPatientAddress'

check box will then put same info into TxtNOKStreet on form fNOKAddress

underlying field is NOKStreet in table tNOK

can you give me anymore info
Many Thanks

On the code page for the form and in the click event for the cechbox
something like this should work
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkSameAsPerson_click()
  2.     Dim db As DAO.Database
  3.     Dim strSQL As String
  4.  
  5.     Set db = CurrentDb 
  6.     strSQL = "UPDATE tNOK SET street='" & TheNameOfThestreetTextbox & "' WHERE TheRelatedField=" TheNameOfTheRelatedFieldTextbox
  7.     db.Execute strSQL
  8.     Set db = Nothing
  9. End Sub
  10.  
Bear in mind that the above will not a work. It is merely an example as you do not have enough info in your question.
So take the above, adjust it to suit your particular problem and use the help files to guide you.

Note that since the controls that contain the address you want to copy are on a subform you will need to take that into account when referencing TheNameOfThestreetTextbox and TheNameOfTheRelatedFieldTextbox etc.

Have a go youself, you will learn more that way. If you stike a barrier then come back and ask here.


PS. The above is only one way to achieve what you want, there are other ways.
Apr 28 '08 #3
Delerna
1,134 Expert 1GB
OK, I will do a mock up database so that I can get the solution right according to what you have and get back to you
Apr 28 '08 #4
Delerna
1,134 Expert 1GB
OK, with the extra info you have provided, here is the easiest way for you to do it.
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkSameAsPerson_Click()
  2.     Forms!fSubDemogs.fNOKAddress.Form!TxtNOKStreet = Forms!fSubDemogs.fPtaddress.Form!TxtPtStreet
  3. End Sub
  4.  

For your information,to do it with my original suggestion
would be something like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub chkSameAsPerson_click()
  2.     Dim db As DAO.Database
  3.     Dim strSQL As String
  4.  
  5.     Set db = CurrentDb 
  6.     strSQL = "UPDATE tNOK SET street='" & Forms!fSubDemogs.fPtaddress.Form!TxtPtStreet & "' WHERE TheRelatedField=" TheNameOfTheRelatedFieldTextbox
  7.     db.Execute strSQL
  8.     Set db = Nothing
  9.     me.refresh
  10. End Sub
  11.  
I still don't know what the related field is. I guess it would be something like patientID
Apr 29 '08 #5

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

Similar topics

1
by: richmarin | last post by:
I am using Access 2002 I have the following task. I have to do a duplicate check on two fields. The logic is, for a given day, and a given id, how many managers shared that same ID on that day....
2
by: Mike N. | last post by:
Hello again.. I have a table with a text field named "Requisition" (Indexed, no dupes). It is not the key field. This field is the first text box on a form. I would like to check to make sure the...
1
by: d9pierce | last post by:
Hi all, I have a company form that I would like to protect against duplication unless checked. Main point being, that I dont want to just be able to add a duplicate company name in a test box...
2
by: Mike Charney | last post by:
I have a temp table that has data I am inserting into a SQL DB table. There is a column in both tables called PAT_ID. I need to check the SQL table against the temp table for duplicate data in...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
5
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
20
by: technocraze | last post by:
Hi guys & commnunity experts, Does anyone knw how to go about checking for existing data in an MS Acess table? I have tried out the following code using vb but doesnt seem to work that well? Can...
3
by: wongray | last post by:
Hello, I need help. I have a form and I would like to do a check when I enter a data into the field and once I press enter into the field it will check whether is duplicate or not. currently...
2
by: Ranma13 | last post by:
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form: If DCount(search for records with...
1
by: gurmet | last post by:
Hi All I have been looking around for help, and finally post this problem. I created a form to edit a record. Before i can click save button on the edit form i need to check if the data that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.