Backup records in Form and SubForm

  • Thread starter Thread starter an
  • Start date Start date
A

an

Hello!

I have a Form and SubForm to based in two Tables with one
to many. They work fine.
My question is:
There are hypothesis to send to T_Backup, all records in
Form and SubForm, with same Id, through query or macro to
run arise from command buttom in Form?
Thanks in advance.
an
 
Forms and Subforms don't have records, they are displays; a way to look at the data

Tables have records

Yes, you can move records from one table to another by (in this order):
1 - running an APPEND query on the many table (T_Homes to T_Homes_BK
2 - running an DELETE query on the many table (T_Homes

3 - running an APPEND query on the one table (T_Names to T_Names_BK
4 - running an DELETE query on the one table (T_Names

The code for the button would look like this

Private Sub Command2_Click(

' Set Warnings Of
DoCmd.SetWarnings Fals

' use your names for the querie

'the many tabl
DoCmd.OpenQuery "T_Homes_APPEND
DoCmd.OpenQuery "T_Homes_DELETE

'the one tabl
DoCmd.OpenQuery "T_Names_APPEND
DoCmd.OpenQuery "T_Names_DELETE

' Set Warnings O
DoCmd.SetWarnings Tru

MsgBox " Done Moving records to the backup tables

End Su

You also need a way to select the PK-FK linking field to use in the queries - usually a combo box

-----------------------------
I think a better way might be to add one field to both tables. Call the field blnHidden (type Yes/No
Run an UPDATE query on both tables to set blnHidden to YES when you don't want to see the records for a name

Add the field to SELECT queries and set the criteria to FALSE. The records with blnHidden set to TRUE won't show

HT

Stev
 
Ok,

Thanks for your replay to my question.
"...all records in Form and SubForm" was an expression...

Lament it isn't possible with one operation. The objective
is the user don't know the backup operation. Only know the
delete operation. Understand me?

Many thanks for tour help.
an

-----Original Message-----
Forms and Subforms don't have records, they are displays; a way to look at the data.

Tables have records.

Yes, you can move records from one table to another by (in this order):
1 - running an APPEND query on the many table (T_Homes to T_Homes_BK)
2 - running an DELETE query on the many table (T_Homes)

3 - running an APPEND query on the one table (T_Names to T_Names_BK)
4 - running an DELETE query on the one table (T_Names)

The code for the button would look like this:

Private Sub Command2_Click()

' Set Warnings Off
DoCmd.SetWarnings False

' use your names for the queries

'the many table
DoCmd.OpenQuery "T_Homes_APPEND"
DoCmd.OpenQuery "T_Homes_DELETE"

'the one table
DoCmd.OpenQuery "T_Names_APPEND"
DoCmd.OpenQuery "T_Names_DELETE"

' Set Warnings On
DoCmd.SetWarnings True

MsgBox " Done Moving records to the backup tables"

End Sub

You also need a way to select the PK-FK linking field to
use in the queries - usually a combo box.tables. Call the field blnHidden (type Yes/No)
Run an UPDATE query on both tables to set blnHidden to
YES when you don't want to see the records for a name.
Add the field to SELECT queries and set the criteria to
FALSE. The records with blnHidden set to TRUE won't show.
 
The person using the database only has to click one button and all four queries will run, in order. The user won't see anything wxcept the finish message

The person making the database can copy the delete query, save it, and change it to an append query

Does this help? Did I understand you correctly

Stev
 
Thanks for your explanation.

My intention is of the other nature.
Logicaly, for final user, the automation of database is
one advantage.

My last step was to create a Macro to make theese
opaerations, but when if to click CANCEL action, display
menu "Action failed..."
Is it possible to surpasse this message and return to back?

Thanks in advance.
an

-----Original Message-----
The person using the database only has to click one
button and all four queries will run, in order. The user
won't see anything wxcept the finish message.
The person making the database can copy the delete query,
save it, and change it to an append query.
 
Back
Top