Sorry, I wasn't next to my computer until now, so I didn't have the mdb you
sent.
Is that the SQL you have in MyQuery
SELECT *
FROM IDEmployeeQuery1
WHERE (((IDEmployeeQuery1.DepartmentID)=[Forms]![BonusForm]![Combo23]) AND
((IDEmployeeQuery1.AreaID)=[Forms]![BonusForm]![Combo25]) AND
((IDEmployeeQuery1.LocationID)=[Forms]![BonusForm]![LocationID])) OR
(((IDEmployeeQuery1.AreaID)=[Forms]![BonusForm]![Combo25]) AND
((IDEmployeeQuery1.LocationID)=[Forms]![BonusForm]![LocationID]) AND
(([Forms]![BonusForm]![Combo23]) Is Null)) OR
(((IDEmployeeQuery1.DepartmentID)=[Forms]![BonusForm]![Combo23]) AND
((IDEmployeeQuery1.LocationID)=[Forms]![BonusForm]![LocationID]) AND
(([Forms]![BonusForm]![Combo25]) Is Null)) OR
(((IDEmployeeQuery1.LocationID)=[Forms]![BonusForm]![LocationID]) AND
(([Forms]![BonusForm]![Combo23]) Is Null) AND
(([Forms]![BonusForm]![Combo25]) Is Null)) OR
(((IDEmployeeQuery1.DepartmentID)=[Forms]![BonusForm]![Combo23]) AND
((IDEmployeeQuery1.AreaID)=[Forms]![BonusForm]![Combo25]) AND
(([Forms]![BonusForm]![LocationID]) Is Null)) OR
(((IDEmployeeQuery1.AreaID)=[Forms]![BonusForm]![Combo25]) AND
(([Forms]![BonusForm]![Combo23]) Is Null) AND
(([Forms]![BonusForm]![LocationID]) Is Null)) OR
(((IDEmployeeQuery1.DepartmentID)=[Forms]![BonusForm]![Combo23]) AND
(([Forms]![BonusForm]![Combo25]) Is Null) AND
(([Forms]![BonusForm]![LocationID]) Is Null)) OR
((([Forms]![BonusForm]![Combo23]) Is Null) AND
(([Forms]![BonusForm]![Combo25]) Is Null) AND
(([Forms]![BonusForm]![LocationID]) Is Null));
--
\\// Live Long and Prosper \\//
BS"D
ldiaz said:
Hi Ofer,that Work copying the column but taking the datas from MyQuery, but I
need it work copying only the Employees filtered in the IDEmployeesubform,
I have tested and it move all rown from Query, example in the subform I have
3 Employees and when I press the Button it copy all records.
I think it's almost finished, but just this is pending.
Thank you so much.
--
Lorenzo DÃaz
Cad Technician
:
Sorry it took me a long time to come back to you
I hope I understand what you are trying to do, two changes that you need to do
1.
The RecordSource of the IDEmployeesubform, save it as query, call it MyQuery
so we can try it.
You can change the Subform RecordSource to this query
2.
To the insert SQL I changed the Query name, the EmployeeID and the IDBonus,
the two fields that required to create a key
DoCmd.RunSQL "INSERT INTO BonusEmployee(EmployeeID, IDBonus) SELECT
EmployeeID , Forms![BonusForm]![IDBonus] As MyId FROM MyQuery"
I hope that what you are looking for, if not then please tell me
Good luck
--
\\// Live Long and Prosper \\//
BS"D
:
I sent you my DataBase already.
Thanks.
--
Lorenzo DÃaz
Cad Technician
:
Hi Lorenzo
I sent you an Email, please send your MDB.
--
\\// Live Long and Prosper \\//
BS"D
:
Hi Ofer,,,I have put all codes in my data Base but it does not work yet,could
you check my DataBase I can send it to you, or do you have an example of this
function.
I will appreciate so much your help, since it is last step that my database
need to be released.
Thanks
(e-mail address removed)
:
About removing the messages you can use this
Docmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BonusEmployee(EmployeeID)SELECT
IDEmployeeQuery1.Name FROM IDEmployeeQuery1"
Docmd.SetWarnings True
About the key violation, check the data you are trying to insert, it could
be that it already exist in the table or atleast some of it, so it prompt you
with the key violation message.
--
\\// Live Long and Prosper \\//
BS"D
:
Hi Ofer.
I pur this code...
DoCmd.RunSQL "INSERT INTO BonusEmployee(EmployeeID)SELECT
IDEmployeeQuery1.Name FROM IDEmployeeQuery1"
Me.[EmployeeBonusSubform].Requery
[BonusEmployeesubform]![EmployeeID] = ([IDEmployeesubform]![EmployeeID])
but when I run the code it show me 3 message saying:
1.You are ppend 6 row(s)
Once click Yes, You can't use the Undo command.are you sure you want to
append the selected rows??
when I press YES appear the 2.
Microsoft office can't append all records in the appened query,and it say
like a Table Violation.
I click Yes then appear the last message:
Microsoft Office can't find the field "I" refered to in your expresion.
can you take a look at it please.
Ldiaz
:
In that case one option will be to use an append query to append all the
records from Query - IDEmployeeQuery1 to Table - BonusEmployee, and then
refresh the Sub form
============================================
Private Sub MoveDatas_Click()
On Error GoTo Err_MoveDatas_Click
Docmd.RunSql "INSERT INTO BonusEmployee( Field1, Field2 )
SELECT IDEmployeeQuery1.Field1, IDEmployeeQuery1.Field2
FROM IDEmployeeQuery1"
Me.[EmployeeBonusSubform].Requery
[BonusEmployeesubform]![EmployeeID] = ([IDEmployeesubform]![EmployeeID])
Exit_MoveDatas_Click:
Exit Sub
Err_MoveDatas_Click:
MsgBox Err.Description
Resume Exit_MoveDatas_Click
End Sub
=============================================
I hope I'm on the right direction
--
\\// Live Long and Prosper \\//
BS"D
:
Hi Ofer,,thank you for answer me...I understand your comments about put the
question to all communty,,I will make it after..
Yes, your are correct, the SubForm (EmployeeIDSubform) is used to filter
Employees, it have a query as source named: IDEmployeeQuery1, the second
subform (EmployeeBonusSubform) has as source a table named: BonusEmployee
where need to be stored all record moved from first subform.
the Problem is because I don' know how move 2 or 3 or more records from a
column to another column,
I filter Employee Using this code in two combobox created in the main form.
SELECT * FROM IDEmployeeQuery1 WHERE ([DepartmentID]=Forms!BonusForm!Combo23
Or Forms!BonusForm!Combo23 Is Null) And ([AreaID]=Forms!BonusForm!Combo25 Or
Forms!BonusForm!Combo25 Is Null) And ([LocationID]=Forms!BonusForm!LocationID
Or Forms!BonusForm!LocationID Is Null);
I have added a Botton named: Private Sub MoveDatas_Click()
On Error GoTo Err_MoveDatas_Click
"""Here I want to put my code to move records of the first subform to the
second subform"""""""
[BonusEmployeesubform]![EmployeeID] = ([IDEmployeesubform]![EmployeeID])
Exit_MoveDatas_Click:
Exit Sub
Err_MoveDatas_Click:
MsgBox Err.Description
Resume Exit_MoveDatas_Click
End Sub
--
Lorenzo DÃaz
Cad Technician
:
Hi Lorenzo, first thank you for your confidence in my abilities, but I'm sure
there are alot of people in the discussion group that can help you just the
same if not better.
To be sure I understand what you need
You have a SubForm (EmployeeIDSubform) that is used to filter the MainForm
(BonusForm).
Now you want to move records to the table that the second SubForm is based
on (EmployeeBonusSubform), my questions are
1. What is the source of this records?
2. How do you filter this records?
3. When do you want this event to happen?
I might be in the wrong direction, so please direct me
--
\\// Live Long and Prosper \\//
BS"D
:
Hi Ofer,I know you can help me...because I have been looking for an answer on
the past weeks but I never got the correct answer.
This is my big problem..