|
Hi, I have been successful copying a vba code from one of your posts on
how to copy and paste a record by declaring the desired fields that
needs to be copied in form's declaration and creating two button "copy"
and "paste". Works like magic.
My problem is how can I copy multiple records and paste them at the
same time. My data entry form has main form that has a Questionlist box
of Questions. The second list box on the same form displays
subquestions based on the selection made in Question list box. The
subform allows to add response for a selected subquestion. Majority of
the time response choices are the same for all the subquestion.
Based on the scenario below, if I do data entry for SubquestionA, I
want to copy/paste all three records to Subquestion B and Subquestion
C.
Question A has
Sub questions A, B, C.
SubQuestion A: Response Choice: 1, 2, 3
SubQuestion B: Response Choice: 1, 2, 3
SubQuestion C: Response Choice: 1, 2, 3
Please let me know how can I achieve that. It will save a lot of time
entering the same records.
Thanks for all your help.
Manjeet | |
Share:
|
Kaur wrote: Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two button "copy" and "paste". Works like magic. My problem is how can I copy multiple records and paste them at the same time. My data entry form has main form that has a Questionlist box of Questions. The second list box on the same form displays subquestions based on the selection made in Question list box. The subform allows to add response for a selected subquestion. Majority of the time response choices are the same for all the subquestion. Based on the scenario below, if I do data entry for SubquestionA, I want to copy/paste all three records to Subquestion B and Subquestion C. Question A has Sub questions A, B, C. SubQuestion A: Response Choice: 1, 2, 3 SubQuestion B: Response Choice: 1, 2, 3 SubQuestion C: Response Choice: 1, 2, 3
Please let me know how can I achieve that. It will save a lot of time entering the same records. Thanks for all your help.
Manjeet
I don't know what your solution is for one record but I should think
that the help file/code examples on ItemsSelected, Selected, ItemCount,
ListIndex...etc will get you what you need to loop through a list. | | |
Thanks for replying.
This is the code I have used.
Option Compare Database
Dim Respondent As String
Dim ResponseNotes As String
Private Sub cmdCopy_Click()
Respondent = Me.RespondentID
ResponseNotes = Me.RespondentGroupNotes
End Sub
Private Sub cmdPaste_Click()
Me.RespondentID = Respondent
Me.RespondentGroupNotes = ResponseNotes
This allows me to copy just the one record in the datasheet subform for
a given subquestion and paste to next subquestion.
I am new to Access so seekin help to resolve this problem.
Thanks
salad wrote: Kaur wrote:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two button "copy" and "paste". Works like magic. My problem is how can I copy multiple records and paste them at the same time. My data entry form has main form that has a Questionlist box of Questions. The second list box on the same form displays subquestions based on the selection made in Question list box. The subform allows to add response for a selected subquestion. Majority of the time response choices are the same for all the subquestion. Based on the scenario below, if I do data entry for SubquestionA, I want to copy/paste all three records to Subquestion B and Subquestion C. Question A has Sub questions A, B, C. SubQuestion A: Response Choice: 1, 2, 3 SubQuestion B: Response Choice: 1, 2, 3 SubQuestion C: Response Choice: 1, 2, 3
Please let me know how can I achieve that. It will save a lot of time entering the same records. Thanks for all your help.
Manjeet I don't know what your solution is for one record but I should think that the help file/code examples on ItemsSelected, Selected, ItemCount, ListIndex...etc will get you what you need to loop through a list. | | |
Kaur wrote: Thanks for replying. This is the code I have used.
Option Compare Database Dim Respondent As String Dim ResponseNotes As String
Private Sub cmdCopy_Click() Respondent = Me.RespondentID ResponseNotes = Me.RespondentGroupNotes End Sub
Private Sub cmdPaste_Click() Me.RespondentID = Respondent Me.RespondentGroupNotes = ResponseNotes
This allows me to copy just the one record in the datasheet subform for a given subquestion and paste to next subquestion.
I am new to Access so seekin help to resolve this problem.
'this enumerates through the listbox. 1st col = 0.
'last col = num of columns-1
Dim var As Variant
Dim rst As DAO.Recordset
set rst = currentdb.openrecordset("TableName",dbopendynaset_
For Each var In Me.ListBoxName.ItemsSelected
rst.AddNew
rst!ID = ListBoxName.Column(0,var)
rst!RespondentGroupNotes = ListBoxName.Column(1,var)
rst.Update
Next
rst.close
set rst = Nothing
This is an example. You should be able to get the gist of it and modify
to suit. Thanks salad wrote:
Kaur wrote:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two button "copy" and "paste". Works like magic. My problem is how can I copy multiple records and paste them at the same time. My data entry form has main form that has a Questionlist box of Questions. The second list box on the same form displays subquestions based on the selection made in Question list box. The subform allows to add response for a selected subquestion. Majority of the time response choices are the same for all the subquestion. Based on the scenario below, if I do data entry for SubquestionA, I want to copy/paste all three records to Subquestion B and Subquestion C. Question A has Sub questions A, B, C. SubQuestion A: Response Choice: 1, 2, 3 SubQuestion B: Response Choice: 1, 2, 3 SubQuestion C: Response Choice: 1, 2, 3
Please let me know how can I achieve that. It will save a lot of time entering the same records. Thanks for all your help.
Manjeet
I don't know what your solution is for one record but I should think that the help file/code examples on ItemsSelected, Selected, ItemCount, ListIndex...etc will get you what you need to loop through a list.
| | |
Thanks for the code. It seems like it takes the records and appends to
the same ID. This is the code I have.
Private Sub cmdPaste_Click()
Dim var As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblRespondent",
dbOpenDynaset)
_
For Each var In Me.LstResp.ItemsSelected
rst.AddNew
rst!RespondentID = LstResp.Column(0, var)
rst!RespondentGroupNotes = LstResp.Column(2, var)
rst!SurveyID = LstResp.Column(3, var)
rst!SurveyEditionID = LstResp.Column(4, var)
rst!QuestionID = LstResp.Column(5, var)
rst!SubQuestionID = LstResp.Column(6, var)
rst.Update
Next
rst.Close
Set rst = Nothing
End Sub
It looks like I am close to the answer to my problem but not there yet.
How do I copy first from first subquestion that has the data populated
with above fields and then go to the next subquestion and append the
records. Right now it will allow me to append these records to the same
subquestion.
Thanks for your time.
salad wrote: Kaur wrote:
Thanks for replying. This is the code I have used.
Option Compare Database Dim Respondent As String Dim ResponseNotes As String
Private Sub cmdCopy_Click() Respondent = Me.RespondentID ResponseNotes = Me.RespondentGroupNotes End Sub
Private Sub cmdPaste_Click() Me.RespondentID = Respondent Me.RespondentGroupNotes = ResponseNotes
This allows me to copy just the one record in the datasheet subform for a given subquestion and paste to next subquestion.
I am new to Access so seekin help to resolve this problem. 'this enumerates through the listbox. 1st col = 0. 'last col = num of columns-1
Dim var As Variant Dim rst As DAO.Recordset set rst = currentdb.openrecordset("TableName",dbopendynaset_ For Each var In Me.ListBoxName.ItemsSelected rst.AddNew rst!ID = ListBoxName.Column(0,var) rst!RespondentGroupNotes = ListBoxName.Column(1,var) rst.Update Next rst.close set rst = Nothing
This is an example. You should be able to get the gist of it and modify to suit.
Thanks salad wrote:
Kaur wrote:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two button "copy" and "paste". Works like magic. My problem is how can I copy multiple records and paste them at the same time. My data entry form has main form that has a Questionlist box of Questions. The second list box on the same form displays subquestions based on the selection made in Question list box. The subform allows to add response for a selected subquestion. Majority of the time response choices are the same for all the subquestion. Based on the scenario below, if I do data entry for SubquestionA, I want to copy/paste all three records to Subquestion B and Subquestion C. Question A has Sub questions A, B, C. SubQuestion A: Response Choice: 1, 2, 3 SubQuestion B: Response Choice: 1, 2, 3 SubQuestion C: Response Choice: 1, 2, 3
Please let me know how can I achieve that. It will save a lot of time entering the same records. Thanks for all your help.
Manjeet
I don't know what your solution is for one record but I should think that the help file/code examples on ItemsSelected, Selected, ItemCount, ListIndex...etc will get you what you need to loop through a list.
| | |
Kaur wrote: Thanks for the code. It seems like it takes the records and appends to the same ID. This is the code I have.
Private Sub cmdPaste_Click()
Dim var As Variant Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("tblRespondent", dbOpenDynaset) _ For Each var In Me.LstResp.ItemsSelected rst.AddNew rst!RespondentID = LstResp.Column(0, var) rst!RespondentGroupNotes = LstResp.Column(2, var) rst!SurveyID = LstResp.Column(3, var) rst!SurveyEditionID = LstResp.Column(4, var) rst!QuestionID = LstResp.Column(5, var) rst!SubQuestionID = LstResp.Column(6, var) rst.Update Next rst.Close Set rst = Nothing End Sub
It looks like I am close to the answer to my problem but not there yet. How do I copy first from first subquestion that has the data populated with above fields and then go to the next subquestion and append the records. Right now it will allow me to append these records to the same subquestion. Thanks for your time.
I am unsure how to answer your problem/question. It's difficult for me
to visualize your form and what exactly it is you need to do.
You have a form. It has 2 list boxes; a Questionlist box of Questions
and then a listbox of subquestions. Then you have a subform that gets
updated...I think. I am unsure what the flow is...what you are
selecting to be updated and what should be updated. Where is the data
coming from? I think/know I would need more info/clarification in order
to help. salad wrote:
Kaur wrote:
Thanks for replying. This is the code I have used.
Option Compare Database Dim Respondent As String Dim ResponseNotes As String
Private Sub cmdCopy_Click() Respondent = Me.RespondentID ResponseNotes = Me.RespondentGroupNotes End Sub
Private Sub cmdPaste_Click() Me.RespondentID = Respondent Me.RespondentGroupNotes = ResponseNotes
This allows me to copy just the one record in the datasheet subform for a given subquestion and paste to next subquestion.
I am new to Access so seekin help to resolve this problem.
'this enumerates through the listbox. 1st col = 0. 'last col = num of columns-1
Dim var As Variant Dim rst As DAO.Recordset set rst = currentdb.openrecordset("TableName",dbopendynaset_ For Each var In Me.ListBoxName.ItemsSelected rst.AddNew rst!ID = ListBoxName.Column(0,var) rst!RespondentGroupNotes = ListBoxName.Column(1,var) rst.Update Next rst.close set rst = Nothing
This is an example. You should be able to get the gist of it and modify to suit.
Thanks salad wrote:
Kaur wrote: >Hi, I have been successful copying a vba code from one of your posts on >how to copy and paste a record by declaring the desired fields that >needs to be copied in form's declaration and creating two button "copy" >and "paste". Works like magic. >My problem is how can I copy multiple records and paste them at the >same time. My data entry form has main form that has a Questionlist box >of Questions. The second list box on the same form displays >subquestions based on the selection made in Question list box. The >subform allows to add response for a selected subquestion. Majority of >the time response choices are the same for all the subquestion. >Based on the scenario below, if I do data entry for SubquestionA, I >want to copy/paste all three records to Subquestion B and Subquestion >C. >Question A has >Sub questions A, B, C. >SubQuestion A: Response Choice: 1, 2, 3 >SubQuestion B: Response Choice: 1, 2, 3 >SubQuestion C: Response Choice: 1, 2, 3 > >Please let me know how can I achieve that. It will save a lot of time >entering the same records. >Thanks for all your help. > >Manjeet >
I don't know what your solution is for one record but I should think that the help file/code examples on ItemsSelected, Selected, ItemCount, ListIndex...etc will get you what you need to loop through a list.
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by David Londeck |
last post: by
|
1 post
views
Thread by andree |
last post: by
|
1 post
views
Thread by Sean Howard |
last post: by
|
2 posts
views
Thread by HB2 |
last post: by
|
1 post
views
Thread by PalJoey |
last post: by
|
reply
views
Thread by igendreau |
last post: by
| | | | | | | | | | | | | |