How do,
I have a access 2000 booking database with Personal Details, Outing Details and the Bookings in three tables: tblBookings -- [Booking ID]-Autonumber, [Outing ID]-Number, [Child ID]-Number, [Amount Paid]-Currency, [Deposit Paid]-Yes/No, [Transport]-Yes/No tblPersonaldeta ils -- [Child ID]-Autonumber, etc tblOutingDetail s -- [Outing ID]-Autonumber, etc
I am trying to restore backups made, but cannot import the bookings into the database as the [Child ID] and [Outing ID] are different than those in the imported tables due to the autonumber data type.
I use this code to firstly import the tables from the backup with the name "[Table Name]Append", delete all the data in the current tables, insert the data from the append tables into the main tables and then delete the append tables. - Private Sub cmdImport_Click()
-
On Error GoTo DeleteAppends
-
Dim strDst, strDstPath, SQLBackuptblBookings, SQLBackuptblOutingDetails, SQLBackuptblPersonalDetails, SQLDeletetblBookingsData, SQLDeletetblOutingDetailsData, SQLDeletetblPersonalDetailsData As String
-
-
strDst = lstRestore
-
strDstPath = CurrentProject.Path & "\Backup\" & strDst
-
-
-
'Import tblBookings from Selected backup and rename it tblBookingsAppend
-
If strDst <> "" Then
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblBookingsBackup", "tblBookingsAppend"
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblOutingDetailsBackup", "tblOutingDetailsAppend"
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblPersonalDetailsBackup", "tblPersonalDetailsAppend"
-
Else
-
msgbox "Please select a Backup to Restore from", , "Select a Backup"
-
Exit Sub
-
End If
-
-
If msgbox("Do you want to restore", vbYesNo, "Restore?") = vbYes Then
-
DoCmd.SetWarnings (False)
-
SQLDeletetblBookingsData = "Delete * FROM tblBookings"
-
SQLDeletetblOutingDetailsData = "Delete * FROM tblOutingDetails"
-
SQLDeletetblPersonalDetailsData = "Delete * FROM tblPersonalDetails"
-
-
SQLBackuptblBookings = "INSERT INTO tblBookings ([Outing ID], [Child ID], [Amount Paid], [Deposit Paid], [Transport]) SELECT [Outing ID], [Child ID], [Amount Paid], [Deposit Paid], [Transport] FROM tblBookingsAppend"
-
SQLBackuptblOutingDetails = "INSERT INTO tblOutingDetails ([Outing Title], [Description], [Age Range], [Date From], [Date To], [Available Places], [Telephone], [E-mail Address], [Address], [Post Code], [Method of Transport], [Cost], [Deposit], [Booking Deadline], [Payment Deadline]) SELECT [Outing Title], [Description], [Age Range], [Date From], [Date To], [Available Places], [Telephone], [E-mail Address], [Address], [Post Code], [Method of Transport], [Cost], [Deposit], [Booking Deadline], [Payment Deadline] FROM tblOutingDetailsAppend"
-
SQLBackuptblPersonalDetails = "INSERT INTO tblPersonalDetails (Surname, Forename, [Date of Birth], Address, [Post Code], [Home Number], [Mobile Number], [E-Mail Address], [Medical Issues], [Dietary Issues]) SELECT Surname, Forename, [Date of Birth], Address, [Post Code], [Home Number], [Mobile Number], [E-Mail Address], [Medical Issues], [Dietary Issues] FROM tblPersonalDetailsAppend"
-
-
-
DoCmd.RunSQL SQLDeletetblBookingsData
-
DoCmd.RunSQL SQLDeletetblOutingDetailsData
-
DoCmd.RunSQL SQLDeletetblPersonalDetailsData
-
-
DoCmd.RunSQL SQLBackuptblOutingDetails
-
DoCmd.RunSQL SQLBackuptblPersonalDetails
-
DoCmd.RunSQL SQLBackuptblBookings
-
-
DoCmd.SetWarnings (True)
-
msgbox "Restore Complete", , "Restore Complete"
-
End If
-
-
'Delete tblBookingsAppend
-
DoCmd.DeleteObject acTable, "tblBookingsAppend"
-
DoCmd.DeleteObject acTable, "tblOutingDetailsAppend"
-
DoCmd.DeleteObject acTable, "tblPersonalDetailsAppend"
-
-
lstRestore.Requery
-
Exit Sub
-
-
DeleteAppends:
-
msgbox Err.Description
-
DoCmd.DeleteObject acTable, "tblBookingsAppend"
-
DoCmd.DeleteObject acTable, "tblOutingDetailsAppend"
-
DoCmd.DeleteObject acTable, "tblPersonalDetailsAppend"
-
lstRestore.Requery
-
Exit Sub
-
-
End Sub
My problem is that once the backup data has been copied over, the autonumber ID fields dont match the ID fields used in the Booking table, so they are not copied over due to Key Violations.
I have thought about this for a while now and have no idea how to resolve the situation.
All help is appreciated,
NDayave
25 2852 ADezii 8,834
Recognized Expert Expert
How do,
I have a access 2000 booking database with Personal Details, Outing Details and the Bookings in three tables: tblBookings -- [Booking ID]-Autonumber, [Outing ID]-Number, [Child ID]-Number, [Amount Paid]-Currency, [Deposit Paid]-Yes/No, [Transport]-Yes/No tblPersonaldeta ils -- [Child ID]-Autonumber, etc tblOutingDetail s -- [Outing ID]-Autonumber, etc
I am trying to restore backups made, but cannot import the bookings into the database as the [Child ID] and [Outing ID] are different than those in the imported tables due to the autonumber data type.
I use this code to firstly import the tables from the backup with the name "[Table Name]Append", delete all the data in the current tables, insert the data from the append tables into the main tables and then delete the append tables. - Private Sub cmdImport_Click()
-
On Error GoTo DeleteAppends
-
Dim strDst, strDstPath, SQLBackuptblBookings, SQLBackuptblOutingDetails, SQLBackuptblPersonalDetails, SQLDeletetblBookingsData, SQLDeletetblOutingDetailsData, SQLDeletetblPersonalDetailsData As String
-
-
strDst = lstRestore
-
strDstPath = CurrentProject.Path & "\Backup\" & strDst
-
-
-
'Import tblBookings from Selected backup and rename it tblBookingsAppend
-
If strDst <> "" Then
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblBookingsBackup", "tblBookingsAppend"
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblOutingDetailsBackup", "tblOutingDetailsAppend"
-
DoCmd.TransferDatabase acImport, "Microsoft Access", strDstPath, acTable, "tblPersonalDetailsBackup", "tblPersonalDetailsAppend"
-
Else
-
msgbox "Please select a Backup to Restore from", , "Select a Backup"
-
Exit Sub
-
End If
-
-
If msgbox("Do you want to restore", vbYesNo, "Restore?") = vbYes Then
-
DoCmd.SetWarnings (False)
-
SQLDeletetblBookingsData = "Delete * FROM tblBookings"
-
SQLDeletetblOutingDetailsData = "Delete * FROM tblOutingDetails"
-
SQLDeletetblPersonalDetailsData = "Delete * FROM tblPersonalDetails"
-
-
SQLBackuptblBookings = "INSERT INTO tblBookings ([Outing ID], [Child ID], [Amount Paid], [Deposit Paid], [Transport]) SELECT [Outing ID], [Child ID], [Amount Paid], [Deposit Paid], [Transport] FROM tblBookingsAppend"
-
SQLBackuptblOutingDetails = "INSERT INTO tblOutingDetails ([Outing Title], [Description], [Age Range], [Date From], [Date To], [Available Places], [Telephone], [E-mail Address], [Address], [Post Code], [Method of Transport], [Cost], [Deposit], [Booking Deadline], [Payment Deadline]) SELECT [Outing Title], [Description], [Age Range], [Date From], [Date To], [Available Places], [Telephone], [E-mail Address], [Address], [Post Code], [Method of Transport], [Cost], [Deposit], [Booking Deadline], [Payment Deadline] FROM tblOutingDetailsAppend"
-
SQLBackuptblPersonalDetails = "INSERT INTO tblPersonalDetails (Surname, Forename, [Date of Birth], Address, [Post Code], [Home Number], [Mobile Number], [E-Mail Address], [Medical Issues], [Dietary Issues]) SELECT Surname, Forename, [Date of Birth], Address, [Post Code], [Home Number], [Mobile Number], [E-Mail Address], [Medical Issues], [Dietary Issues] FROM tblPersonalDetailsAppend"
-
-
-
DoCmd.RunSQL SQLDeletetblBookingsData
-
DoCmd.RunSQL SQLDeletetblOutingDetailsData
-
DoCmd.RunSQL SQLDeletetblPersonalDetailsData
-
-
DoCmd.RunSQL SQLBackuptblOutingDetails
-
DoCmd.RunSQL SQLBackuptblPersonalDetails
-
DoCmd.RunSQL SQLBackuptblBookings
-
-
DoCmd.SetWarnings (True)
-
msgbox "Restore Complete", , "Restore Complete"
-
End If
-
-
'Delete tblBookingsAppend
-
DoCmd.DeleteObject acTable, "tblBookingsAppend"
-
DoCmd.DeleteObject acTable, "tblOutingDetailsAppend"
-
DoCmd.DeleteObject acTable, "tblPersonalDetailsAppend"
-
-
lstRestore.Requery
-
Exit Sub
-
-
DeleteAppends:
-
msgbox Err.Description
-
DoCmd.DeleteObject acTable, "tblBookingsAppend"
-
DoCmd.DeleteObject acTable, "tblOutingDetailsAppend"
-
DoCmd.DeleteObject acTable, "tblPersonalDetailsAppend"
-
lstRestore.Requery
-
Exit Sub
-
-
End Sub
My problem is that once the backup data has been copied over, the autonumber ID fields dont match the ID fields used in the Booking table, so they are not copied over due to Key Violations.
I have thought about this for a while now and have no idea how to resolve the situation.
All help is appreciated,
NDayave
What are the exact Relationships among the 3 Tables? It seems like:
tblPersonalDeta ils.[Child ID]( 1) ==> tblBookings.[Child ID]( Many)
tblOutgoingDeta ils.[Outing ID]( 1) ==> tblBookings.[Outing ID]( Many)
The problem may be with the Append Sequence as opposed to different IDs.
Yeah, those are all the relationships there are.
whats happening is:
restoring old data with a Child ID of 3
in bookings table the booking is therefore under Child ID of 3
Because you cannot (to my knowledge) change autonumbers, the imported Data is given a new Child ID: 5
The imported booking table however, still holds a Child ID of 3, which is now either non-existant or just wrong. This then stops the import of the booking due to key violations.
On a side note, do you know how to set a text box with an input mask to always start at the left no matter where you click in the text box. Its a little problem but it annoys me.
Thanks,
NDayave
MSeda 159
Recognized Expert New Member
if this is a split database you can have the back up replace the entire backend as a whole rather than a table at a time. that way would not disturb the relationships or autonumbers.
if this is a split database you can have the back up replace the entire backend as a whole rather than a table at a time. that way would not disturb the relationships or autonumbers.
By split database i have no idea what you mean. The backups are held in seperate dated databases, and imported in to the main database when restored.
How would you go about replacing the entire 'Backend'?
Cheers
NDayave
ADezii 8,834
Recognized Expert Expert
Yeah, those are all the relationships there are.
whats happening is:
restoring old data with a Child ID of 3
in bookings table the booking is therefore under Child ID of 3
Because you cannot (to my knowledge) change autonumbers, the imported Data is given a new Child ID: 5
The imported booking table however, still holds a Child ID of 3, which is now either non-existant or just wrong. This then stops the import of the booking due to key violations.
On a side note, do you know how to set a text box with an input mask to always start at the left no matter where you click in the text box. Its a little problem but it annoys me.
Thanks,
NDayave
On the side note:
__1 Set the Text Alignment of the Field to Left via: Format ==> Text Align ==> Left.
__2 You can also set an Exclamation Point (!) in the Format Property to force Left Alignment of values.
__3 The other issue is more complicated, but I am working on it. Please be patient.
ADezii 8,834
Recognized Expert Expert
On the side note:
__1 Set the Text Alignment of the Field to Left via: Format ==> Text Align ==> Left.
__2 You can also set an Exclamation Point (!) in the Format Property to force Left Alignment of values.
__3 The other issue is more complicated, but I am working on it. Please be patient.
I think I have a solution for your Primary Problem but I'm afraid it's a little confusing. I will keep an eye on this Post and see if someone comes up with a better idea.
NeoPa 32,568
Recognized Expert Moderator MVP
MSeda touched on this point, but you cannot restore half a set of linked data and hope for it to make sense.
You need to make clear why you are trying to restore the booking data without the related (Child) data being restored at the same time.
Aside from that, when restoring linked data, it is necessary to rebuild the data which links to the related table(s). In this case, it is not enough simply to restore the tblBooking table. You must rebuild it from the existing data. It seems you need to re-engineer your backup process if you need to save simply the bookings. It is a restriction of AutoNumber fields that you cannot put a value into them so, thinking about it you'll probably need to re-engineer your backup AND restore procedures anyway.
When Backing up, you must include all relevant data with the booking. Any links to AutoNumber fields must be padded out with data uniquely identifying the item without reliance on the autonumber field. This can be done without successive data overhead if they are stored in a separate table in the backup too, but they must be saved somehow.
On restore, the linked item (Child) should be determined from the backup data prior to creating a new link in the live database.
I think I have a solution for your Primary Problem but I'm afraid it's a little confusing. I will keep an eye on this Post and see if someone comes up with a better idea.
Hit me with it, all help is appreciated.
Provided it works, i dont care if it takes an age to understand, I believe they call it learning...
Thanks,
NDayave
MSeda touched on this point, but you cannot restore half a set of linked data and hope for it to make sense.
You need to make clear why you are trying to restore the booking data without the related (Child) data being restored at the same time.
Aside from that, when restoring linked data, it is necessary to rebuild the data which links to the related table(s). In this case, it is not enough simply to restore the tblBooking table. You must rebuild it from the existing data. It seems you need to re-engineer your backup process if you need to save simply the bookings. It is a restriction of AutoNumber fields that you cannot put a value into them so, thinking about it you'll probably need to re-engineer your backup AND restore procedures anyway.
When Backing up, you must include all relevant data with the booking. Any links to AutoNumber fields must be padded out with data uniquely identifying the item without reliance on the autonumber field. This can be done without successive data overhead if they are stored in a separate table in the backup too, but they must be saved somehow.
On restore, the linked item (Child) should be determined from the backup data prior to creating a new link in the live database.
Sorry to cause confusion, all the data in all 3 tables is being restored from a backup. The problem is that the auto number asigns the imported Child ID in the Personal Details table a new number, so the imported value in the Bookings table no longer corresponds.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dave Robinson |
last post by:
I was wondering if anyone could help me with a problem I'm having.
I've been using Dreamweaver to create a hotel booking system for a
friend of mine, using MySQL (version 4.0.21) and PHP 5. The bit I'm
struggling with is checking the Room Availability based on dates that
are typed into a textfield and then returning a list of the available
rooms on the next page.
The three tables involved in this function are:
CREATE TABLE `room` (
|
by: Jim Andersen |
last post by:
Hi there,
After compacting/repairing a db, I was getting duplicate autonumbers.
According to MS KB article
http://support.microsoft.com/default.aspx?kbid=257408
This should be fixed with a Jet service pack.
The mentioned SP6 is apparently not available, but I found SP8. Have now
|
by: WiseOwl |
last post by:
Hi folks
I teach. At school, four IT rooms are booked using a paper based outline
timetable. Completing it is easy but basic and impossible to ensure
completion of all fields (name, year group, subject and software) and
analysis of bookings is a nightmare.
I just fancied pottering with Access, which I am pretty familiar with, to
see if I could create a means of booking a room using a database. Locking a
booking would then be a...
|
by: Andy |
last post by:
Hi folks
I teach. At school, four IT rooms are booked using a paper based outline
timetable. Completing it is easy but basic and impossible to ensure
completion of all fields (name, year group, subject and software) and
analysis of bookings is a nightmare.
I just fancied pottering with Access, which I am pretty familiar with, to
see if I could create a means of booking a room using a database. Locking a
booking would then be a...
|
by: Megan |
last post by:
Hi everybody-
I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite...
| |
by: thegame21 |
last post by:
Hi, I am currently creating a cinema system using access where a
booking can be made for a event. Each event when it is shown is
categoriesd as a performance. A booking must be made for each
performamce. I have a constructed a query between the booking, event
and peformance tables and created a subform on the booking form. The
event table is linked to the performance table which in turn is linked
to the booking table. I keep on getting the...
|
by: Polani |
last post by:
Hi Guys ,
I am taking DB2 Online backups through TSM API daily. When i check the
database configuration parameters , it shows me " Number of database
backup verions to maintain"= 12.
This is also shown when i check " db2 list history db " it showed me 12
versions of backups which is ok, but problem is that when i run
"db2adutl query" it showed me 69 or 70 entries like that:::
|
by: feeman |
last post by:
Not sure if this is possible but I am working on a database, that
requires the following function. Be able to book a job in for a given
week of the year, and this then becomes unavailable for anyone else to
book the same week.
I need to be able to do this for multiple people, so they do not get
double booked for jobs.
Anybody got any ideas.
|
by: Julie Smith |
last post by:
Hi,
I have a question about autonumbers in Access db. How are they assigned when
adding a new row to a table?
I have table that has an autonumber column (replication ID/System.Guid) and
a name column. When making a new row, I assign the name, then add the row to
the table. I would have thought that the autonumber would be automatically
given, but this does not seem to be the case.
Can anyone help me?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |