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

Moving Data from one RS to another RS

Hi Guys,

I'm very new to access and I've been trying to get the hang of it over the last few days, but I've become very confused with various aspects of how to code it.

Introduction:
I am using 3 tables for my data base at the moment. The first table is an ID table, which tracks IDs that are in use/taken. The second table is a queue, which has very little/limited information on a person. The third table is a log, which has much more data on a person. The user enters in the first name, last name, and telephone number and the data gets transferred from the queue table to the log table.


Goals:
-Move data from queue to log(make new entry in log).
-Assign new log entry an ID number, add ID entry to ID table.
-Delete entry from queue where the data had been taken from.



Code:

Private Sub MoveEntry_Click()
Dim db As Database
Dim QD As QueryDef
Dim QD2 As QueryDef
Dim rsA As DAO.Recordset
Dim rsB As DAO.Recordset

'The 3 Primary Key Values for Both Tables that should be entered into the form

If IsNull(FirstNameT) Then
MsgBox "Please Enter First Name", vbCritical, "Invalid First Name"
Exit Sub
End If

If IsNull(LastNameT) Then
MsgBox "Please Enter Last Name", vbCritical, "Invalid Last Name"
Exit Sub
End If

If IsNull(PhoneT) Then
MsgBox "Please Enter Phone Number", vbCritical, "Invalid Phone Number"
Exit Sub
End If

Set db = CurrentDb()

On Error Resume Next
db.QueryDefs.Delete ("Move_Queue_Query")
On Error GoTo 0

Set QD = db.CreateQueryDef("Move_Queue_Query", _
"Select Count(*) from [Call Queue] where [Last Name] = Me![LastNameT] AND [First Name] = Me![FirstNameT] AND [Phone Number] = Me![PhoneT];")
DoCmd.OpenQuery "Move_Queue_Query"

'ADD CODE HERE TO PROCESS COUNT

'ADD CODE TO SET ID
Set QD2 = db.CreateQueryDef(Select Max(ID) from [ID Log])
'ADD CODE TO PROCESS MAX + 1
Set rsC = db.OpenRecordset("ID Log")
rsC.AddNew
rsC("ID") = Max+1
rsC.Update
rsC.Close

'ADD CODE TO ACCESS CORRECT QUEUE ENTRY
Set rsA = db.OpenRecordset("Call Queue")
Set rsB = db.OpenRecordset("Call Log")
rsB.AddNew
rsB("ID") = ID
rsB("Date") = rsA("Date")
rsB("Time") = rsA("Time")
rsB("Last Name") = rsA("Last Name")
rsB("First Name") = rsA("First Name")
rsB("Phone Number") = rsA("Phone Number")
rsB("Notes") = rsA(Comments) + ", " + NotesT
rsB("Suggestions") = SuggestT
rsB.Update
rsB.Close

'ADD CODE TO DELETE RECORD FROM rsA

rsA.Close
Set rsA = Nothing
Set rsB = Nothing
Set rsC = Nothing
Set db = Nothing

MsgBox "Added " + FirstNameT + " " + LastNameT, , "Success"
DoCmd.Close
End Sub



Known Problems:

So far, I do not know if I'm using QueryDefs right at all. But I have two in there.

The first one does a count to check if there exists an entry in the queue table that matches the first name, last name, telephone number. If this is a good way to do it so far, I need help on how to process the count. Is the querydef another table? Do I just grab the value? Or is there a way to store the count into a variable somewhere so I can just do a comparison statement like count ==1?

The second querydef does a max on the ID table to find out what the maximum value is. Similar to the first question, is there a way to store tha max into a value and then just add 1 to it and set that as the new ID number?

Next, accessing the correct record in the queue log to transfer information. Do I do that the same way I did the other querydefs? Is there a more effecient way to do it?

Lastly, I would like to understand how to delete the record I assessed from the queue table.



Thank you for reading this long problem. Any help would be greatly appreciated. I apoligize if some of these problems are routine and simple, I've tried looking on google but maybe I'm not typing in the right keywords
Dec 28 '06 #1
1 1921
NeoPa
32,556 Expert Mod 16PB
Let's forget this long complicated question and build up from scratch.
Precision and accuracy are very important in communicating remotely.
Q1. Do you have a form that an operator enters detail into which then populates the Queue table?
If not, please respecify the basic requirements without the necessity of working it out from your code.
We will need shortly, a post with your MetaData laid out.
Here is an example of how to post table MetaData :
Posting Table/Dataset MetaData
Expand|Select|Wrap|Line Numbers
  1. Table Name=tblStudent
  2. StudentID; Autonumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. MaxMark; Numeric
  7. MinMark; Numeric
Dec 30 '06 #2

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

Similar topics

4
by: Stephen Ghelerter | last post by:
I am moving a web site with a MySql database to another server. Can I create a database on the new server with the same name and then move the tables there, or is life not that simple? Or can I...
2
by: Todd D. Levy | last post by:
I am moving 3 fields & associated data from 1 table to another. I will have to make the necessary changes to forms, code, queries, & reports, etc. It is the reports, and the queries that they...
3
by: genojoe | last post by:
I have tried everything I can think of to move records from one Access database to another. It should not be that hard. Read on.... I have identical access mdb's. One contains data; one...
3
by: Iavor Raytchev | last post by:
Hello, We a situation with a central database that contains the data that needs to be presented at N off-line terminals (N can be 5 000 can be 15 000). Each terminal presents unique data. The...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
3
by: UJ | last post by:
I've got a working web service that we are moving to another machine and now I suddenly get the following error. While transferring the files, got the following message:...
3
by: jay.meerdink | last post by:
Greetings! I have a simple Windows form for editing. Search results are bound to a bindingsource and shown in a datagrid paired with a datanavigator. The current row's data is displayed in text...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
In a database search application (vb2005), the user wants to be able to scroll through records using the mousewheel. The data display form contains textboxes for the main data and a datagridview...
0
by: jvitti | last post by:
I recently upgraded from Access 2000 to Access 2007 and I am having trouble with moving the focus from 1 form to another. While doing data entry if a similar claim is found the claim view form...
15
by: mcjason | last post by:
I saw something interesting about a grid pair puzzle problem that it looks like a machine when you find each that work out the way it does and say with all the others that work out the way they...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.