Duplicating data to different tables
Posted by admin on 25 Sep 2008 at 10:28 PM
$5.00
Sorry, perhaps I was not too clear. There is no error message that come us.
It's a debug problem. The line below gets highlighted and the code stops running. The editor opens.
Followup To
Question -
Thanks. I am sure the code works, since you wrote it a few times ago...
By the way, the line which gets highlited in yellow is:
Set MyRs = MyDb.OpenRecordset("APPLICATIONS")
Perhaps what I am doing wrong is trying to copy the data into a different table without having the form which I use to store its data, opened.
Basically the active form which I am using is named CLAIMS (in my prior e-mail I inverted the names, sorry). I use the CLAIMS form to store data into my table named CLAIMS. I have added the code to the cmbbutton stored on my form CLAIMS to copy the records to the table APPLICATIONS.
On the OnClick I would like that these records are copied into the table APPLICATIONS.
Hope this helps. Thanks.
-------------------------
Followup To
Question -
Hello Scott,
some time ago you gave me a great help with the code below to duplicate data into the same table.
The code below in on the click event of a button on a form named APPLICATIONS. I use it to duplicate some records into the same table.
I know I should not be doing this but I find it very useful.
I have now been asked to duplicate the same records to a different table named CLAIMS.
I would like to add the code behind a button on the same form named APPLICATIONS. I have simply tried to copy the code but it gives me an error message. SOmething to do with MyRs.
What I would like is to copy that data into the other table without having the form opening.
Do you think is possible?
Thanks.
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("APPLICATIONS")
MyRs.AddNew
MyRs!SSN = Forms!APPLICATIONS!SSN
MyRs!FNAME = Forms!APPLICATIONS!FNAME
MyRs!LNAME = Forms!APPLICATIONS!LNAME
MyRs!RECEIVED = Forms!APPLICATIONS!RECEIVED
MyRs!CLOSED = Forms!APPLICATIONS!CLOSED
MyRs!INITIALS = Forms!APPLICATIONS!INITIALS
MyRs!ADDRESS1 = Forms!APPLICATIONS!ADDRESS1
MyRs!ADDRESS2 = Forms!APPLICATIONS!ADDRESS2
MyRs!CITY = Forms!APPLICATIONS!CITY
MyRs!ZIP = Forms!APPLICATIONS!ZIP
MyRs!Country = Forms!APPLICATIONS!Country
MyRs!PHONE = Forms!APPLICATIONS!PHONE
MyRs.Update
strCode = DMax("[ID]", "Applications")
strFilter = "(([ID] = " & strCode & ")) "
DoCmd.ApplyFilter , strFilter
Me.Refresh
Me.CODE.SetFocus
If IsNull([CODE]) Then
MsgBox "Please enter the Claim TYPE!. ", vbOKOnly
Me!CODE.SetFocus
End If
Answer -
The code looks good. When you get an error message you need to provide the exact message. If I know what the message is I may be able to figure out what was wrong.
Hope this helps,
Scott<>
Answer -
Well the Applications form definitely needs to be open. But if the Set line is being highlighted then something is wrong with that line. The error message may tell me what.
Scott<>
It's a debug problem. The line below gets highlighted and the code stops running. The editor opens.
Followup To
Question -
Thanks. I am sure the code works, since you wrote it a few times ago...
By the way, the line which gets highlited in yellow is:
Set MyRs = MyDb.OpenRecordset("APPLICATIONS")
Perhaps what I am doing wrong is trying to copy the data into a different table without having the form which I use to store its data, opened.
Basically the active form which I am using is named CLAIMS (in my prior e-mail I inverted the names, sorry). I use the CLAIMS form to store data into my table named CLAIMS. I have added the code to the cmbbutton stored on my form CLAIMS to copy the records to the table APPLICATIONS.
On the OnClick I would like that these records are copied into the table APPLICATIONS.
Hope this helps. Thanks.
-------------------------
Followup To
Question -
Hello Scott,
some time ago you gave me a great help with the code below to duplicate data into the same table.
The code below in on the click event of a button on a form named APPLICATIONS. I use it to duplicate some records into the same table.
I know I should not be doing this but I find it very useful.
I have now been asked to duplicate the same records to a different table named CLAIMS.
I would like to add the code behind a button on the same form named APPLICATIONS. I have simply tried to copy the code but it gives me an error message. SOmething to do with MyRs.
What I would like is to copy that data into the other table without having the form opening.
Do you think is possible?
Thanks.
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("APPLICATIONS")
MyRs.AddNew
MyRs!SSN = Forms!APPLICATIONS!SSN
MyRs!FNAME = Forms!APPLICATIONS!FNAME
MyRs!LNAME = Forms!APPLICATIONS!LNAME
MyRs!RECEIVED = Forms!APPLICATIONS!RECEIVED
MyRs!CLOSED = Forms!APPLICATIONS!CLOSED
MyRs!INITIALS = Forms!APPLICATIONS!INITIALS
MyRs!ADDRESS1 = Forms!APPLICATIONS!ADDRESS1
MyRs!ADDRESS2 = Forms!APPLICATIONS!ADDRESS2
MyRs!CITY = Forms!APPLICATIONS!CITY
MyRs!ZIP = Forms!APPLICATIONS!ZIP
MyRs!Country = Forms!APPLICATIONS!Country
MyRs!PHONE = Forms!APPLICATIONS!PHONE
MyRs.Update
strCode = DMax("[ID]", "Applications")
strFilter = "(([ID] = " & strCode & ")) "
DoCmd.ApplyFilter , strFilter
Me.Refresh
Me.CODE.SetFocus
If IsNull([CODE]) Then
MsgBox "Please enter the Claim TYPE!. ", vbOKOnly
Me!CODE.SetFocus
End If
Answer -
The code looks good. When you get an error message you need to provide the exact message. If I know what the message is I may be able to figure out what was wrong.
Hope this helps,
Scott<>
Answer -
Well the Applications form definitely needs to be open. But if the Set line is being highlighted then something is wrong with that line. The error message may tell me what.
Scott<>
Accepted Answer:
| Answer provided by admin on 25 Sep 2008 at 10:28 PM If you are getting a Debug option there IS an error message. It will state that an error has occured with some sort of explanation and asking if you want to Debug or End. |
| Rating: * * * * * Awarded: $5.00 |
Ask a Question
Most Recent Questions
Most Recent Answers
Home Page
Login
Register
Information Technology
Programming Languages
Database
- Microsoft Access
- MySQL
- Oracle
- PostGreSQL
- SQL Server
- Visual FoxPro
Graphic Design
Operating Platforms
Hardware and Networking
Math and Science
Biology and Geology
Math and Statistics
Chemistry
Physics
Engineering

Are you an information
Most Recent Questions
Most Recent Answers
Home Page
Login
Register
Information Technology
Software, Hardware, Design
Programming LanguagesDatabase
- Microsoft Access
- MySQL
- Oracle
- PostGreSQL
- SQL Server
- Visual FoxPro
Graphic Design
Operating Platforms
Hardware and Networking
Math and Science
Homework Help
Biology and GeologyMath and Statistics
Chemistry
Physics
Engineering
Are you an information
technology or
math/science expert?
You can earn money by
providing answers to questions
at AnswerArchive.com.
Learn How